Package org.apache.struts.config

Examples of org.apache.struts.config.ModuleConfig


                TagUtils.getInstance().saveException(pageContext, e);
                throw e;
            }

            ModuleConfig config =
                (ModuleConfig) pageContext.getRequest().getAttribute(Globals.MODULE_KEY);

            HttpServletRequest request =
                (HttpServletRequest) pageContext.getRequest();

            String pageValue = this.page;

            if (config != null) {
                pageValue =
                    TagUtils.getInstance().pageURL(request, this.page, config);
            }

            return (request.getContextPath() + pageValue);
        }

        // Deal with an indirect context-relative page that has been specified
        if (this.pageKey != null) {
            if ((this.src != null) || (this.srcKey != null)) {
                JspException e =
                    new JspException(messages.getMessage("imgTag.src"));

                TagUtils.getInstance().saveException(pageContext, e);
                throw e;
            }

            ModuleConfig config =
                (ModuleConfig) pageContext.getRequest().getAttribute(Globals.MODULE_KEY);

            HttpServletRequest request =
                (HttpServletRequest) pageContext.getRequest();
View Full Code Here


    public ModuleConfig createModuleConfig(
      String moduleName,
      String configFileName,
      boolean moduleAware) {
           
      ModuleConfig moduleConfig =
        ModuleConfigFactory.createFactory().createModuleConfig(moduleName);
           
      context.setAttribute(Globals.MODULE_KEY + moduleName, moduleConfig);
   
      // Set tiles plugin
      PlugInConfig pluginConfig = new PlugInConfig();
      pluginConfig.setClassName("org.apache.struts.tiles.TilesPlugin");
       
      pluginConfig.addProperty(
        "moduleAware",
        (moduleAware == true ? "true" : "false"));
           
      pluginConfig.addProperty(
        "definitions-config",
        "/org/apache/struts/tiles/config/" + configFileName);
           
      moduleConfig.addPlugInConfig(pluginConfig);
      return moduleConfig;
    }
View Full Code Here

    private Map initLookupMap(HttpServletRequest request, Locale userLocale) {
        Map lookupMap = new HashMap();

        this.keyMethodMap = this.getKeyMethodMap();

        ModuleConfig moduleConfig =
            (ModuleConfig) request.getAttribute(Globals.MODULE_KEY);

        MessageResourcesConfig[] mrc =
            moduleConfig.findMessageResourcesConfigs();

        // Look through all module's MessageResources
        for (int i = 0; i < mrc.length; i++) {
            MessageResources resources =
                this.getResources(request, mrc[i].getKey());
View Full Code Here

        context.setAttribute(Globals.MODULE_PREFIXES_KEY, prefixes);
        request.setPathElements("/myapp", "/2/noform.do", null, null);

        ModuleUtils.getInstance().selectModule(request, context);

        ModuleConfig moduleConfig =
            (ModuleConfig) request.getAttribute(Globals.MODULE_KEY);

        assertNotNull("Selected a module", moduleConfig);
        assertEquals("Selected correct module", "/2", moduleConfig.getPrefix());

        // FIXME - check module resources?
    }
View Full Code Here

    public void testSelectApplication2a() {
        request.setPathElements("/myapp", "/2/noform.do", null, null);
        request.setAttribute(RequestProcessor.INCLUDE_SERVLET_PATH, "/noform.do");
        ModuleUtils.getInstance().selectModule(request, context);

        ModuleConfig moduleConfig =
            (ModuleConfig) request.getAttribute(Globals.MODULE_KEY);

        assertNotNull("Selected an application", moduleConfig);
        assertEquals("Selected correct application", "",
            moduleConfig.getPrefix());

        // FIXME - check application resources?
    }
View Full Code Here

        request.setPathElements("/myapp", "/noform.do", null, null);
        request.setAttribute(RequestProcessor.INCLUDE_SERVLET_PATH,
            "/2/noform.do");
        ModuleUtils.getInstance().selectModule(request, context);

        ModuleConfig moduleConfig =
            (ModuleConfig) request.getAttribute(Globals.MODULE_KEY);

        assertNotNull("Selected a module", moduleConfig);
        assertEquals("Selected correct module", "/2", moduleConfig.getPrefix());

        // FIXME - check application resources?
    }
View Full Code Here

    }

    // ----public ModuleConfig getModuleConfig(PageContext pageContext)
    public void testModuleConfig_getModuleConfig_PageContext() {
        MockServletConfig mockServletConfig = new MockServletConfig();
        ModuleConfig moduleConfig = new ModuleConfigImpl("");
        MockServletContext mockServletContext = new MockServletContext();
        MockHttpServletRequest mockHttpServletRequest =
            new MockHttpServletRequest();
        MockHttpServletResponse mockHttpServletResponse =
            new MockHttpServletResponse();

        mockServletConfig.setServletContext(mockServletContext);

        MockPageContext mockPageContext =
            new MockPageContext(mockServletConfig, mockHttpServletRequest,
                mockHttpServletResponse);

        ModuleConfig foundModuleConfig = null;

        try {
            foundModuleConfig = tagutils.getModuleConfig(mockPageContext);
            fail("Expected ModuleConfig to not be found");
        } catch (NullPointerException ignore) {
View Full Code Here

            TagUtils.getInstance().saveException(pageContext, e);
            throw e;
        }

        // Retrieve our module configuration information
        ModuleConfig config =
            TagUtils.getInstance().getModuleConfig(pageContext);

        // Retrieve the requested object to be exposed
        Object object = null;
        String selector = null;

        if (formBean != null) {
            selector = formBean;
            object = config.findFormBeanConfig(formBean);
        } else if (forward != null) {
            selector = forward;
            object = config.findForwardConfig(forward);
        } else if (mapping != null) {
            selector = mapping;
            object = config.findActionConfig(mapping);
        }

        if (object == null) {
            JspException e =
                new JspException(messages.getMessage("struts.missing", selector));
View Full Code Here

    // Map to the default module -- direct
    public void testSelectApplication1a() {
        request.setPathElements("/myapp", "/noform.do", null, null);
        ModuleUtils.getInstance().selectModule(request, context);

        ModuleConfig moduleConfig =
            (ModuleConfig) request.getAttribute(Globals.MODULE_KEY);

        assertNotNull("Selected a module", moduleConfig);
        assertEquals("Selected correct module", "", moduleConfig.getPrefix());

        // FIXME - check module resources?
    }
View Full Code Here

     * @throws JspException if a JSP exception has occurred
     */
    public int doEndTag() throws JspException {
        // Look up the desired ActionForward entry
        ActionForward forward = null;
        ModuleConfig config =
            TagUtils.getInstance().getModuleConfig(pageContext);

        if (config != null) {
            forward = (ActionForward) config.findForwardConfig(name);
        }

        if (forward == null) {
            JspException e =
                new JspException(messages.getMessage("forward.lookup", name));

            TagUtils.getInstance().saveException(pageContext, e);
            throw e;
        }

        // Forward or redirect to the corresponding actual path
        String path = forward.getPath();

        path = config.getPrefix() + path;

        if (forward.getRedirect()) {
            this.doRedirect(path);
        } else {
            this.doForward(path);
View Full Code Here

TOP

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

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.