Package org.apache.struts.action

Examples of org.apache.struts.action.ActionFormBean


        String name = request.getParameter("name");
        if (name == null)
            writer.println("FAIL - Missing 'name' parameter");
        else {
            ActionFormBean formBean = getServlet().findFormBean(name);
            if (formBean == null)
                writer.println("FAIL - Unknown form bean '" + name + "'");
            else {
                getServlet().removeFormBean(formBean);
                writer.println("OK");
View Full Code Here


         HttpServletRequest request,
         HttpServletResponse response)
  throws IOException, ServletException {

        // Construct a new ActionFormBean instance
        ActionFormBean formBean = null;
        try {
            Class clazz = Class.forName(getServlet().getFormBeanClass());
            formBean = (ActionFormBean) clazz.newInstance();
        } catch (Throwable t) {
            throw new ServletException("ActionFormBean", t);
        }
        RequestUtils.populate(formBean, request);

        // Validate the parameters of the new instance
        boolean ok = true;
        response.setContentType("text/plain");
        PrintWriter writer = response.getWriter();
        if (formBean.getName() == null) {
            writer.println("FAIL - Missing 'name' parameter");
            ok = false;
        }
        if (formBean.getType() == null) {
            writer.println("FAIL - Missing 'type' parameter");
            ok = false;
        }
        if (!ok) {
            writer.flush();
View Full Code Here

    }


    protected void setUpDefaultApp() {

        ActionFormBean formBean = null;
        ActionForward forward = null;
        ActionMapping mapping = null;

        appConfig = new ApplicationConfig("");
        context.setAttribute(Action.APPLICATION_KEY, appConfig);

        // Forward "external" to "http://jakarta.apache.org/"
        appConfig.addForwardConfig
            (new ActionForward("external", "http://jakarta.apache.org/",
                               false, false));

        // Forward "foo" to "/bar.jsp"
        appConfig.addForwardConfig
            (new ActionForward("foo", "/bar.jsp", false, false));

        // Forward "relative1" to "relative.jsp" non-context-relative
        appConfig.addForwardConfig
            (new ActionForward("relative1", "relative.jsp", false, false));

        // Forward "relative2" to "relative.jsp" context-relative
        appConfig.addForwardConfig
            (new ActionForward("relative2", "relative.jsp", false, true));

        // Form Bean "static" is a standard ActionForm subclass
        formBean = new ActionFormBean
            ("static",
             "org.apache.struts.mock.MockFormBean");
        appConfig.addFormBeanConfig(formBean);

        // Action "/static" uses the "static" form bean in request scope
        mapping = new ActionMapping();
        mapping.setInput("/static.jsp");
        mapping.setName("static");
        mapping.setPath("/static");
        mapping.setScope("request");
        mapping.setType("org.apache.struts.mock.MockAction");
        appConfig.addActionConfig(mapping);

        // Form Bean "dynamic" is a DynaActionForm with the same properties
        formBean = new ActionFormBean
            ("dynamic",
             "org.apache.struts.action.DynaActionForm");
        formBean.addFormPropertyConfig
            (new FormPropertyConfig("booleanProperty", "boolean", "false"));
        formBean.addFormPropertyConfig
            (new FormPropertyConfig("stringProperty", "java.lang.String",
                                    null));
        appConfig.addFormBeanConfig(formBean);

        // Action "/dynamic" uses the "dynamic" form bean in session scope
        mapping = new ActionMapping();
        mapping.setInput("/dynamic.jsp");
        mapping.setName("dynamic");
        mapping.setPath("/dynamic");
        mapping.setScope("session");
        mapping.setType("org.apache.struts.mock.MockAction");
        appConfig.addActionConfig(mapping);

        // Form Bean "/dynamic0" is a DynaActionForm with initializers
        formBean = new ActionFormBean
            ("dynamic0",
             "org.apache.struts.action.DynaActionForm");
        formBean.addFormPropertyConfig
            (new FormPropertyConfig("booleanProperty", "boolean", "true"));
        formBean.addFormPropertyConfig
            (new FormPropertyConfig("stringProperty", "java.lang.String",
                                    "String Property"));
        formBean.addFormPropertyConfig
            (new FormPropertyConfig("intArray1", "int[]",
                                    "{1,2,3}", 4)); // 4 should be ignored
        formBean.addFormPropertyConfig
            (new FormPropertyConfig("intArray2", "int[]",
                                    null, 5)); // 5 should be respected
        formBean.addFormPropertyConfig
            (new FormPropertyConfig("principal",
                                    "org.apache.struts.mock.MockPrincipal",
                                    null));
        formBean.addFormPropertyConfig
            (new FormPropertyConfig("stringArray1", "java.lang.String[]",
                                    "{aaa,bbb,ccc}", 2)); // 2 should be ignored
        formBean.addFormPropertyConfig
            (new FormPropertyConfig("stringArray2", "java.lang.String[]",
                                    null, 3)); // 3 should be respected
        appConfig.addFormBeanConfig(formBean);

        // Action "/dynamic0" uses the "dynamic0" form bean in request scope
View Full Code Here

    }


    protected void setUpSecondApp() {

        ActionFormBean formBean = null;
        ActionMapping mapping = null;

        appConfig2 = new ApplicationConfig("/2");
        context.setAttribute(Action.APPLICATION_KEY + "/2", appConfig2);

        // Forward "external" to "http://jakarta.apache.org/"
        appConfig2.addForwardConfig
            (new ActionForward("external", "http://jakarta.apache.org/",
                               false, false));

        // Forward "foo" to "/baz.jsp" (different from default)
        appConfig2.addForwardConfig
            (new ActionForward("foo", "/baz.jsp", false, false));

        // Forward "relative1" to "relative.jsp" non-context-relative
        appConfig2.addForwardConfig
            (new ActionForward("relative1", "relative.jsp", false, false));

        // Forward "relative2" to "relative.jsp" context-relative
        appConfig2.addForwardConfig
            (new ActionForward("relative2", "relative.jsp", false, true));

        // Form Bean "static" is a standard ActionForm subclass (same as default)
        formBean = new ActionFormBean
            ("static",
             "org.apache.struts.mock.MockFormBean");
        appConfig2.addFormBeanConfig(formBean);

        // Action "/static" uses the "static" form bean in request scope (same as default)
        mapping = new ActionMapping();
        mapping.setInput("/static.jsp");
        mapping.setName("static");
        mapping.setPath("/static");
        mapping.setScope("request");
        mapping.setType("org.apache.struts.mock.MockAction");
        appConfig2.addActionConfig(mapping);

        // Form Bean "dynamic2" is a DynaActionForm with the same properties
        formBean = new ActionFormBean
            ("dynamic2",
             "org.apache.struts.action.DynaActionForm");
        formBean.addFormPropertyConfig
            (new FormPropertyConfig("booleanProperty", "boolean", "false"));
        formBean.addFormPropertyConfig
            (new FormPropertyConfig("stringProperty", "java.lang.String",
                                    null));
        appConfig2.addFormBeanConfig(formBean);

        // Action "/dynamic2" uses the "dynamic2" form bean in session scope
View Full Code Here

        ActionMapping mapping = findMapping(path);
        String name = mapping.getName();

        ActionForm form = null;

        ActionFormBean formBean = findFormBean(name);
        if (formBean != null) {
            String className = null;
            className = formBean.getType();
            try {
                Class clazz = Class.forName(className);
                form = (ActionForm) clazz.newInstance();
            } catch (Throwable t) {
                form = null;
View Full Code Here

    }


    protected void setUpDefaultApp() {

        ActionFormBean formBean = null;
        ActionForward forward = null;
        ActionMapping mapping = null;

        appConfig = new ApplicationConfig("");
        context.setAttribute(Action.APPLICATION_KEY, appConfig);

        // Forward "external" to "http://jakarta.apache.org/"
        appConfig.addForwardConfig
            (new ActionForward("external", "http://jakarta.apache.org/",
                               false, false));

        // Forward "foo" to "/bar.jsp"
        appConfig.addForwardConfig
            (new ActionForward("foo", "/bar.jsp", false, false));

        // Forward "relative1" to "relative.jsp" non-context-relative
        appConfig.addForwardConfig
            (new ActionForward("relative1", "relative.jsp", false, false));

        // Forward "relative2" to "relative.jsp" context-relative
        appConfig.addForwardConfig
            (new ActionForward("relative2", "relative.jsp", false, true));

        // Form Bean "static" is a standard ActionForm subclass
        formBean = new ActionFormBean
            ("static",
             "org.apache.struts.mock.MockFormBean");
        appConfig.addFormBeanConfig(formBean);

        // Action "/static" uses the "static" form bean in request scope
        mapping = new ActionMapping();
        mapping.setInput("/static.jsp");
        mapping.setName("static");
        mapping.setPath("/static");
        mapping.setScope("request");
        mapping.setType("org.apache.struts.mock.MockAction");
        appConfig.addActionConfig(mapping);

        // Form Bean "dynamic" is a DynaActionForm with the same properties
        formBean = new ActionFormBean
            ("dynamic",
             "org.apache.struts.action.DynaActionForm");
        formBean.addFormPropertyConfig
            (new FormPropertyConfig("booleanProperty", "boolean", "false"));
        formBean.addFormPropertyConfig
            (new FormPropertyConfig("stringProperty", "java.lang.String",
                                    null));
        appConfig.addFormBeanConfig(formBean);

        // Action "/dynamic" uses the "dynamic" form bean in session scope
View Full Code Here

    }


    protected void setUpSecondApp() {

        ActionFormBean formBean = null;
        ActionMapping mapping = null;

        appConfig2 = new ApplicationConfig("/2");
        context.setAttribute(Action.APPLICATION_KEY + "/2", appConfig2);

        // Forward "external" to "http://jakarta.apache.org/"
        appConfig2.addForwardConfig
            (new ActionForward("external", "http://jakarta.apache.org/",
                               false, false));

        // Forward "foo" to "/baz.jsp" (different from default)
        appConfig2.addForwardConfig
            (new ActionForward("foo", "/baz.jsp", false, false));

        // Forward "relative1" to "relative.jsp" non-context-relative
        appConfig2.addForwardConfig
            (new ActionForward("relative1", "relative.jsp", false, false));

        // Forward "relative2" to "relative.jsp" context-relative
        appConfig2.addForwardConfig
            (new ActionForward("relative2", "relative.jsp", false, true));

        // Form Bean "static" is a standard ActionForm subclass (same as default)
        formBean = new ActionFormBean
            ("static",
             "org.apache.struts.mock.MockFormBean");
        appConfig2.addFormBeanConfig(formBean);

        // Action "/static" uses the "static" form bean in request scope (same as default)
        mapping = new ActionMapping();
        mapping.setInput("/static.jsp");
        mapping.setName("static");
        mapping.setPath("/static");
        mapping.setScope("request");
        mapping.setType("org.apache.struts.mock.MockAction");
        appConfig2.addActionConfig(mapping);

        // Form Bean "dynamic2" is a DynaActionForm with the same properties
        formBean = new ActionFormBean
            ("dynamic2",
             "org.apache.struts.action.DynaActionForm");
        formBean.addFormPropertyConfig
            (new FormPropertyConfig("booleanProperty", "boolean", "false"));
        formBean.addFormPropertyConfig
            (new FormPropertyConfig("stringProperty", "java.lang.String",
                                    null));
        appConfig2.addFormBeanConfig(formBean);

        // Action "/dynamic2" uses the "dynamic2" form bean in session scope
View Full Code Here

    }


    protected void setUpDefaultApp() {

        ActionFormBean formBean = null;
        ActionMapping mapping = null;

        ModuleConfigFactory factoryObject = ModuleConfigFactory.createFactory();
        moduleConfig = factoryObject.createModuleConfig("");

        context.setAttribute(Globals.MODULE_KEY, moduleConfig);

        // Forward "external" to "http://jakarta.apache.org/"
        moduleConfig.addForwardConfig
            (new ActionForward("external", "http://jakarta.apache.org/",
                               false, false));

        // Forward "foo" to "/bar.jsp"
        moduleConfig.addForwardConfig
            (new ActionForward("foo", "/bar.jsp", false, false));

        // Forward "relative1" to "relative.jsp" non-context-relative
        moduleConfig.addForwardConfig
            (new ActionForward("relative1", "relative.jsp", false, false));

        // Forward "relative2" to "relative.jsp" context-relative
        moduleConfig.addForwardConfig
            (new ActionForward("relative2", "relative.jsp", false, true));

        // Form Bean "static" is a standard ActionForm subclass
        formBean = new ActionFormBean
            ("static",
             "org.apache.struts.mock.MockFormBean");
        moduleConfig.addFormBeanConfig(formBean);

        // Action "/static" uses the "static" form bean in request scope
        mapping = new ActionMapping();
        mapping.setInput("/static.jsp");
        mapping.setName("static");
        mapping.setPath("/static");
        mapping.setScope("request");
        mapping.setType("org.apache.struts.mock.MockAction");
        moduleConfig.addActionConfig(mapping);

        // Form Bean "dynamic" is a DynaActionForm with the same properties
        formBean = new ActionFormBean
            ("dynamic",
             "org.apache.struts.action.DynaActionForm");
        formBean.addFormPropertyConfig
            (new FormPropertyConfig("booleanProperty", "boolean", "false"));
        formBean.addFormPropertyConfig
            (new FormPropertyConfig("stringProperty", "java.lang.String",
                                    null));
        moduleConfig.addFormBeanConfig(formBean);

        // Action "/dynamic" uses the "dynamic" form bean in session scope
        mapping = new ActionMapping();
        mapping.setInput("/dynamic.jsp");
        mapping.setName("dynamic");
        mapping.setPath("/dynamic");
        mapping.setScope("session");
        mapping.setType("org.apache.struts.mock.MockAction");
        moduleConfig.addActionConfig(mapping);

        // Form Bean "/dynamic0" is a DynaActionForm with initializers
        formBean = new ActionFormBean
            ("dynamic0",
             "org.apache.struts.action.DynaActionForm");
        formBean.addFormPropertyConfig
            (new FormPropertyConfig("booleanProperty", "boolean", "true"));
        formBean.addFormPropertyConfig
            (new FormPropertyConfig("stringProperty", "java.lang.String",
                                    "String Property"));
        formBean.addFormPropertyConfig
            (new FormPropertyConfig("intArray1", "int[]",
                                    "{1,2,3}", 4)); // 4 should be ignored
        formBean.addFormPropertyConfig
            (new FormPropertyConfig("intArray2", "int[]",
                                    null, 5)); // 5 should be respected
        formBean.addFormPropertyConfig
            (new FormPropertyConfig("principal",
                                    "org.apache.struts.mock.MockPrincipal",
                                    null));
        formBean.addFormPropertyConfig
            (new FormPropertyConfig("stringArray1", "java.lang.String[]",
                                    "{aaa,bbb,ccc}", 2)); // 2 should be ignored
        formBean.addFormPropertyConfig
            (new FormPropertyConfig("stringArray2", "java.lang.String[]",
                                    null, 3)); // 3 should be respected
        moduleConfig.addFormBeanConfig(formBean);

        // Action "/dynamic0" uses the "dynamic0" form bean in request scope
View Full Code Here

    }


    protected void setUpSecondApp() {

        ActionFormBean formBean = null;
        ActionMapping mapping = null;


        ModuleConfigFactory factoryObject = ModuleConfigFactory.createFactory();
        moduleConfig2 = factoryObject.createModuleConfig("/2");

        context.setAttribute(Globals.MODULE_KEY + "/2", moduleConfig2);

        // Forward "external" to "http://jakarta.apache.org/"
        moduleConfig2.addForwardConfig
            (new ActionForward("external", "http://jakarta.apache.org/",
                               false, false));

        // Forward "foo" to "/baz.jsp" (different from default)
        moduleConfig2.addForwardConfig
            (new ActionForward("foo", "/baz.jsp", false, false));

        // Forward "relative1" to "relative.jsp" non-context-relative
        moduleConfig2.addForwardConfig
            (new ActionForward("relative1", "relative.jsp", false, false));

        // Forward "relative2" to "relative.jsp" context-relative
        moduleConfig2.addForwardConfig
            (new ActionForward("relative2", "relative.jsp", false, true));

        // Form Bean "static" is a standard ActionForm subclass (same as default)
        formBean = new ActionFormBean
            ("static",
             "org.apache.struts.mock.MockFormBean");
        moduleConfig2.addFormBeanConfig(formBean);

        // Action "/static" uses the "static" form bean in request scope (same as default)
        mapping = new ActionMapping();
        mapping.setInput("/static.jsp");
        mapping.setName("static");
        mapping.setPath("/static");
        mapping.setScope("request");
        mapping.setType("org.apache.struts.mock.MockAction");
        moduleConfig2.addActionConfig(mapping);

        // Form Bean "dynamic2" is a DynaActionForm with the same properties
        formBean = new ActionFormBean
            ("dynamic2",
             "org.apache.struts.action.DynaActionForm");
        formBean.addFormPropertyConfig
            (new FormPropertyConfig("booleanProperty", "boolean", "false"));
        formBean.addFormPropertyConfig
            (new FormPropertyConfig("stringProperty", "java.lang.String",
                                    null));
        moduleConfig2.addFormBeanConfig(formBean);

        // Action "/dynamic2" uses the "dynamic2" form bean in session scope
View Full Code Here

    }


    protected void setUpDefaultApp() {

        ActionFormBean formBean = null;
        ActionForward forward = null;
        ActionMapping mapping = null;

        appConfig = new ApplicationConfig("");
        context.setAttribute(Action.APPLICATION_KEY, appConfig);

        // Forward "external" to "http://jakarta.apache.org/"
        appConfig.addForwardConfig
            (new ActionForward("external", "http://jakarta.apache.org/",
                               false, false));

        // Forward "foo" to "/bar.jsp"
        appConfig.addForwardConfig
            (new ActionForward("foo", "/bar.jsp", false, false));

        // Forward "relative1" to "relative.jsp" non-context-relative
        appConfig.addForwardConfig
            (new ActionForward("relative1", "relative.jsp", false, false));

        // Forward "relative2" to "relative.jsp" context-relative
        appConfig.addForwardConfig
            (new ActionForward("relative2", "relative.jsp", false, true));

        // Form Bean "static" is a standard ActionForm subclass
        formBean = new ActionFormBean
            ("static",
             "org.apache.struts.mock.MockFormBean");
        appConfig.addFormBeanConfig(formBean);

        // Action "/static" uses the "static" form bean in request scope
        mapping = new ActionMapping();
        mapping.setInput("/static.jsp");
        mapping.setName("static");
        mapping.setPath("/static");
        mapping.setScope("request");
        mapping.setType("org.apache.struts.mock.MockAction");
        appConfig.addActionConfig(mapping);

        // Form Bean "dynamic" is a DynaActionForm with the same properties
        formBean = new ActionFormBean
            ("dynamic",
             "org.apache.struts.action.DynaActionForm");
        formBean.addFormPropertyConfig
            (new FormPropertyConfig("booleanProperty", "boolean", "false"));
        formBean.addFormPropertyConfig
            (new FormPropertyConfig("stringProperty", "java.lang.String",
                                    null));
        appConfig.addFormBeanConfig(formBean);

        // Action "/dynamic" uses the "dynamic" form bean in session scope
        mapping = new ActionMapping();
        mapping.setInput("/dynamic.jsp");
        mapping.setName("dynamic");
        mapping.setPath("/dynamic");
        mapping.setScope("session");
        mapping.setType("org.apache.struts.mock.MockAction");
        appConfig.addActionConfig(mapping);

        // Form Bean "/dynamic0" is a DynaActionForm with initializers
        formBean = new ActionFormBean
            ("dynamic0",
             "org.apache.struts.action.DynaActionForm");
        formBean.addFormPropertyConfig
            (new FormPropertyConfig("booleanProperty", "boolean", "true"));
        formBean.addFormPropertyConfig
            (new FormPropertyConfig("stringProperty", "java.lang.String",
                                    "String Property"));
        formBean.addFormPropertyConfig
            (new FormPropertyConfig("intArray1", "int[]",
                                    "{1,2,3}", 4)); // 4 should be ignored
        formBean.addFormPropertyConfig
            (new FormPropertyConfig("intArray2", "int[]",
                                    null, 5)); // 5 should be respected
        formBean.addFormPropertyConfig
            (new FormPropertyConfig("principal",
                                    "org.apache.struts.mock.MockPrincipal",
                                    null));
        formBean.addFormPropertyConfig
            (new FormPropertyConfig("stringArray1", "java.lang.String[]",
                                    "{aaa,bbb,ccc}", 2)); // 2 should be ignored
        formBean.addFormPropertyConfig
            (new FormPropertyConfig("stringArray2", "java.lang.String[]",
                                    null, 3)); // 3 should be respected
        appConfig.addFormBeanConfig(formBean);

        // Action "/dynamic0" uses the "dynamic0" form bean in request scope
View Full Code Here

TOP

Related Classes of org.apache.struts.action.ActionFormBean

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.