Package org.apache.struts.config

Examples of org.apache.struts.config.FormPropertyConfig


        // 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
        mapping = new ActionMapping();
View Full Code Here


        // 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
        mapping = new ActionMapping();
View Full Code Here

            // ... and the property configs
            FormPropertyConfig[] fpcs = formBean.findFormPropertyConfigs();

            for (int j = 0; j < fpcs.length; j++) {
                FormPropertyConfig property = fpcs[j];

                if (property.getType() == null) {
                    handleValueRequiredException("type", property.getName(),
                        "form property");
                }
            }

            // Force creation and registration of DynaActionFormClass instances
View Full Code Here

        FormBeanConfig barFBC = new FormBeanConfig();

        barFBC.setName("bar");
        barFBC.setType("org.apache.struts.action.DynaActionForm"); // use a different type so we can verify lookups better

        FormPropertyConfig fpc = new FormPropertyConfig();

        fpc.setName("property");
        fpc.setType("java.lang.String");
        fpc.setInitial("test");
        barFBC.addFormPropertyConfig(fpc);
        moduleConfig.addFormBeanConfig(barFBC);

        ActionConfig testActionConfig = new ActionConfig();
View Full Code Here

        baseFormBean = new FormBeanConfig();
        baseFormBean.setName("baseForm");
        baseFormBean.setType("org.apache.struts.action.DynaActionForm");

        // Set up id, name, and score
        FormPropertyConfig property = new FormPropertyConfig();

        property.setName("id");
        property.setType("java.lang.String");
        baseFormBean.addFormPropertyConfig(property);

        property = new FormPropertyConfig();
        property.setName("name");
        property.setType("java.lang.String");
        baseFormBean.addFormPropertyConfig(property);

        property = new FormPropertyConfig();
        property.setName("score");
        property.setType("java.lang.String");
        baseFormBean.addFormPropertyConfig(property);

        // Setup the exception handler
        baseException = new ExceptionConfig();
        baseException.setType("java.lang.NullPointerException");
View Full Code Here

    }

    // -------------------------------------------------- Verify FormBeanConfig
    // Check for ability to add a property before and after freezing
    public void testConfigAdd() {
        FormPropertyConfig prop = null;

        // Before freezing
        prop = beanConfig.findFormPropertyConfig("fooProperty");
        assertNull("fooProperty not found", prop);
        beanConfig.addFormPropertyConfig(new FormPropertyConfig("fooProperty",
                "java.lang.String", ""));
        prop = beanConfig.findFormPropertyConfig("fooProperty");
        assertNotNull("fooProperty found", prop);

        // after freezing
        beanConfig.freeze();
        prop = beanConfig.findFormPropertyConfig("barProperty");
        assertNull("barProperty not found", prop);

        try {
            beanConfig.addFormPropertyConfig(new FormPropertyConfig(
                    "barProperty", "java.lang.String", ""));
            fail("barProperty add not prevented");
        } catch (IllegalStateException e) {
            ; // Expected result
        }
View Full Code Here

            "org.apache.struts.action.DynaActionForm", beanConfig.getType());
    }

    // Check attempts to add a duplicate property name
    public void testConfigDuplicate() {
        FormPropertyConfig prop = null;

        assertNull("booleanProperty is found", prop);

        try {
            beanConfig.addFormPropertyConfig(new FormPropertyConfig(
                    "booleanProperty", "java.lang.String", ""));
            fail("Adding duplicate property not prevented");
        } catch (IllegalArgumentException e) {
            ; // Expected result
        }
View Full Code Here

    }

    // Check the configured FormPropertyConfig element properties
    public void testConfigProperties() {
        for (int i = 0; i < dynaProperties.length; i++) {
            FormPropertyConfig dynaProperty =
                beanConfig.findFormPropertyConfig(dynaProperties[i].getName());

            assertNotNull("Found dynaProperty " + dynaProperties[i].getName(),
                dynaProperty);
            assertEquals("dynaProperty name for " + dynaProperties[i].getName(),
                dynaProperties[i].getName(), dynaProperty.getName());
            assertEquals("dynaProperty type for " + dynaProperties[i].getName(),
                dynaProperties[i].getType(), dynaProperty.getType());
            assertEquals("dynaProperty initial for "
                + dynaProperties[i].getName(), dynaProperties[i].getInitial(),
                dynaProperty.getInitial());
        }
    }
View Full Code Here

        }
    }

    // Check for ability to remove a property before and after freezing
    public void testConfigRemove() {
        FormPropertyConfig prop = null;

        // Before freezing
        prop = beanConfig.findFormPropertyConfig("booleanProperty");
        assertNotNull("booleanProperty found", prop);
        beanConfig.removeFormPropertyConfig(prop);
View Full Code Here

        // 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
        mapping = new ActionMapping();
View Full Code Here

TOP

Related Classes of org.apache.struts.config.FormPropertyConfig

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.