Package org.apache.struts.action

Examples of org.apache.struts.action.ActionMapping


        jsFormName = formName;

        if (jsFormName.charAt(0) == '/') {
            String mappingName =
                TagUtils.getInstance().getActionMappingName(jsFormName);
            ActionMapping mapping =
                (ActionMapping) config.findActionConfig(mappingName);

            if (mapping == null) {
                JspException e =
                    new JspException(messages.getMessage("formTag.mapping",
                            mappingName));

                pageContext.setAttribute(Globals.EXCEPTION_KEY, e,
                    PageContext.REQUEST_SCOPE);
                throw e;
            }

            jsFormName = mapping.getAttribute();
        }

        results.append(this.getJavascriptBegin(methods));

        for (Iterator i = actions.iterator(); i.hasNext();) {
View Full Code Here


    }

    public void testCheckMultipleSubstitutions() {
        ActionMapping[] mapping = new ActionMapping[1];

        mapping[0] = new ActionMapping();
        mapping[0].setPath("/foo*");
        mapping[0].setName("name,{1}-{1}");

        ActionConfigMatcher matcher = new ActionConfigMatcher(mapping);
        ActionConfig m = matcher.match("/fooBar");
View Full Code Here

        assertTrue("Name hasn't been replaced correctly: " + m.getName(),
            "name,Bar-Bar".equals(m.getName()));
    }

    private ActionConfig buildActionConfig(String path) {
        ActionMapping mapping = new ActionMapping();

        mapping.setName("name,{1}");
        mapping.setPath(path);
        mapping.setScope("request");
        mapping.setUnknown(false);
        mapping.setValidate(true);

        mapping.setPrefix("foo,{1}");
        mapping.setSuffix("bar,{1}");

        mapping.setType("foo.bar.{1}Action");
        mapping.setRoles("public,{1}");
        mapping.setParameter("param,{1}");
        mapping.setAttribute("attrib,{1}");
        mapping.setForward("fwd,{1}");
        mapping.setInclude("include,{1}");
        mapping.setInput("input,{1}");

        ForwardConfig cfg = new ActionForward();

        cfg.setName("name");
        cfg.setPath("path,{1}");
        cfg.setModule("mod{1}");
        cfg.setProperty("foo", "bar,{1}");
        mapping.addForwardConfig(cfg);

        cfg = new ActionForward();
        cfg.setName("name2");
        cfg.setPath("path2");
        cfg.setModule("mod{1}");
        mapping.addForwardConfig(cfg);

        ExceptionConfig excfg = new ExceptionConfig();

        excfg.setKey("foo");
        excfg.setType("foo.Bar");
        excfg.setPath("path");
        mapping.addExceptionConfig(excfg);

        excfg = new ExceptionConfig();
        excfg.setKey("foo2");
        excfg.setType("foo.Bar2");
        excfg.setPath("path2");
        mapping.addExceptionConfig(excfg);

        mapping.setProperty("testprop", "testval");
        mapping.setProperty("testprop2", "test{1}");

        mapping.freeze();

        return mapping;
    }
View Full Code Here

        String mockMappingName = "mockMapping";
        String stringValue     = "Test";

        MockFormBean  mockForm = new MockFormBean();
        ActionMapping mapping  = new ActionMapping();
        mapping.setName(mockMappingName);

        // Set up the mock HttpServletRequest
        request.setMethod("POST");
        request.setContentType("multipart/form-data");
        request.setAttribute(Globals.MULTIPART_KEY, MockMultipartRequestHandler.class.getName());
        request.setAttribute(Globals.MAPPING_KEY, mapping);

        request.addParameter("stringProperty", stringValue);
        request.addParameter("multipartRequestHandler.mapping.name", "Bad");

        // Check the Mapping/ActionForm before
        assertNull("Multipart Handler already set",    mockForm.getMultipartRequestHandler());
        assertEquals("Mapping name not set correctly", mockMappingName, mapping.getName());

        // Try to populate
        try {
            RequestUtils.populate(mockForm, request);
        } catch(ServletException se) {
            // Expected BeanUtils.populate() to throw a NestedNullException
            // which gets wrapped in RequestUtils in a ServletException
            assertEquals("Unexpected type of Exception thrown", "BeanUtils.populate", se.getMessage());
        }

        // Check the Mapping/ActionForm after
        assertNotNull("Multipart Handler Missing", mockForm.getMultipartRequestHandler());
        assertEquals("Mapping name has been modified", mockMappingName, mapping.getName());

    }
View Full Code Here

    // ----------------------------------------------------- createActionForm()
    // Default module -- No ActionForm should be created
    public void testCreateActionForm1a() {
        request.setPathElements("/myapp", "/noform.do", null, null);

        ActionMapping mapping =
            (ActionMapping) moduleConfig.findActionConfig("/noform");

        assertNotNull("Found /noform mapping", mapping);

        ActionForm form =
View Full Code Here

    // Second module -- No ActionForm should be created
    public void testCreateActionForm1b() {
        request.setPathElements("/myapp", "/2/noform.do", null, null);

        ActionMapping mapping =
            (ActionMapping) moduleConfig2.findActionConfig("/noform");

        assertNotNull("Found /noform mapping", mapping);

        ActionForm form =
View Full Code Here

    // Default module -- Standard ActionForm should be created
    public void testCreateActionForm2a() {
        request.setPathElements("/myapp", "/static.do", null, null);

        ActionMapping mapping =
            (ActionMapping) moduleConfig.findActionConfig("/static");

        assertNotNull("Found /static mapping", mapping);
        assertNotNull("Mapping has non-null name", mapping.getName());
        assertEquals("Mapping has correct name", "static", mapping.getName());
        assertNotNull("AppConfig has form bean " + mapping.getName(),
            moduleConfig.findFormBeanConfig(mapping.getName()));

        ActionForm form =
            RequestUtils.createActionForm(request, mapping, moduleConfig, null);

        assertNotNull("ActionForm returned", form);
View Full Code Here

    // Second module -- Standard ActionForm should be created
    public void testCreateActionForm2b() {
        request.setPathElements("/myapp", "/2/static.do", null, null);

        ActionMapping mapping =
            (ActionMapping) moduleConfig2.findActionConfig("/static");

        assertNotNull("Found /static mapping", mapping);
        assertNotNull("Mapping has non-null name", mapping.getName());
        assertEquals("Mapping has correct name", "static", mapping.getName());
        assertNotNull("AppConfig has form bean " + mapping.getName(),
            moduleConfig.findFormBeanConfig(mapping.getName()));

        ActionForm form =
            RequestUtils.createActionForm(request, mapping, moduleConfig2, null);

        assertNotNull("ActionForm returned", form);
View Full Code Here

    // Default module -- Dynamic ActionForm should be created
    public void testCreateActionForm3a() {
        request.setPathElements("/myapp", "/dynamic.do", null, null);

        ActionMapping mapping =
            (ActionMapping) moduleConfig.findActionConfig("/dynamic");

        assertNotNull("Found /dynamic mapping", mapping);
        assertNotNull("Mapping has non-null name", mapping.getName());
        assertEquals("Mapping has correct name", "dynamic", mapping.getName());
        assertNotNull("AppConfig has form bean " + mapping.getName(),
            moduleConfig.findFormBeanConfig(mapping.getName()));

        ActionForm form =
            RequestUtils.createActionForm(request, mapping, moduleConfig, null);

        assertNotNull("ActionForm returned", form);
View Full Code Here

    // Second module -- Dynamic ActionForm should be created
    public void testCreateActionForm3b() {
        request.setPathElements("/myapp", "/2/dynamic2.do", null, null);

        ActionMapping mapping =
            (ActionMapping) moduleConfig2.findActionConfig("/dynamic2");

        assertNotNull("Found /dynamic2 mapping", mapping);
        assertNotNull("Mapping has non-null name", mapping.getName());
        assertEquals("Mapping has correct name", "dynamic2", mapping.getName());
        assertNotNull("AppConfig has form bean " + mapping.getName(),
            moduleConfig2.findFormBeanConfig(mapping.getName()));

        ActionForm form =
            RequestUtils.createActionForm(request, mapping, moduleConfig2, null);

        assertNotNull("ActionForm returned", form);
View Full Code Here

TOP

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

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.