Package org.apache.struts.config

Examples of org.apache.struts.config.ModuleConfig


        throws Exception {
        // Identify the matching path for this request
        String path = getPath(actionCtx);

        // Cache the corresponding ActonConfig instance
        ModuleConfig moduleConfig = actionCtx.getModuleConfig();
        ActionConfig actionConfig = moduleConfig.findActionConfig(path);

        if (actionConfig == null) {
            // NOTE Shouldn't this be the responsibility of ModuleConfig?
            // Locate the mapping for unknown paths (if any)
            ActionConfig[] configs = moduleConfig.findActionConfigs();

            for (int i = 0; i < configs.length; i++) {
                if (configs[i].getUnknown()) {
                    actionConfig = configs[i];
View Full Code Here


     * requires this API-dependent subclass of AbstractCreateAction.
     */
    protected synchronized Action getAction(ActionContext context, String type,
        ActionConfig actionConfig)
        throws Exception {
        ModuleConfig moduleConfig = actionConfig.getModuleConfig();
        String actionsKey = Constants.ACTIONS_KEY + moduleConfig.getPrefix();
        Map actions = (Map) context.getApplicationScope().get(actionsKey);

        if (actions == null) {
            actions = new HashMap();
            context.getApplicationScope().put(actionsKey, actions);
View Full Code Here

     *  located for this application module
     */
    public void createActionForm(FacesContext context) {

        // Look up the application module configuration information we need
        ModuleConfig moduleConfig = lookupModuleConfig(context);

        // Look up the ActionConfig we are processing
        String action = getAction();
        ActionConfig actionConfig = moduleConfig.findActionConfig(action);
        if (actionConfig == null) {
            throw new IllegalArgumentException("Cannot find action '" +
                                               action + "' configuration");
        }

        // Does this ActionConfig specify a form bean?
        String name = actionConfig.getName();
        if (name == null) {
            return;
        }

        // Look up the FormBeanConfig we are processing
        FormBeanConfig fbConfig = moduleConfig.findFormBeanConfig(name);
        if (fbConfig == null) {
            throw new IllegalArgumentException("Cannot find form bean '" +
                                               name + "' configuration");
        }

View Full Code Here

     *  can be found
     */
    public ModuleConfig lookupModuleConfig(FacesContext context) {

        // Look up the application module configuration information we need
        ModuleConfig modConfig = (ModuleConfig)
            context.getExternalContext().getRequestMap().get
            (Globals.MODULE_KEY);
        if (modConfig == null) {
            modConfig = (ModuleConfig)
                context.getExternalContext().getApplicationMap().get
View Full Code Here

     * @throws ServletException if an unrecoverable error occurs.
     */
    public void handleRequest(HttpServletRequest request)
        throws ServletException {
        // Get the app config for the current request.
        ModuleConfig ac =
            (ModuleConfig) request.getAttribute(Globals.MODULE_KEY);

        // Create and configure a DIskFileUpload instance.
        DiskFileUpload upload = new DiskFileUpload();

View Full Code Here

    /**
     * Test the creation of a Struts 1.x ModuleConfig wrapper around an XWork PackageConfig.
     * The PackageConfig is loaded from test-struts-factory.xml.
     */
    public void testCreateModuleConfig() {
        ModuleConfig moduleConfig = factory.createModuleConfig(PACKAGE_NAME);
        assertNotNull(moduleConfig);
       
        assertEquals("/"+PACKAGE_NAME, moduleConfig.getPrefix());
       
        ActionConfig actionConfig = moduleConfig.findActionConfig("/action1");
        assertNotNull(actionConfig);
        assertEquals("/action1", actionConfig.getPath());
       
        ActionConfig[] actionConfigs = moduleConfig.findActionConfigs();
        assertNotNull(actionConfigs);
        assertEquals(2, actionConfigs.length);
       
        ExceptionConfig exceptionConfig = moduleConfig.findExceptionConfig(Exception.class.getName());
        assertNotNull(exceptionConfig);
        assertEquals(Exception.class.getName(), exceptionConfig.getType());
       
        ExceptionConfig[] exceptionConfigs = moduleConfig.findExceptionConfigs();
        assertNotNull(exceptionConfigs);
        assertEquals(1, exceptionConfigs.length);
       
        ForwardConfig fwdConfig = moduleConfig.findForwardConfig("globalResult");
        assertNotNull(fwdConfig);
        assertEquals("globalResult", fwdConfig.getName());
       
        // These methods are currently not implemented -- replace as functionality is added.
        assertNYI(moduleConfig, "getControllerConfig", null);
View Full Code Here

        ExceptionConfig[] exceptionConfigs = mapping.findExceptionConfigs();
        assertNotNull(exceptionConfigs);
        assertEquals(2, exceptionConfigs.length);
       
        ModuleConfig moduleConfig = mapping.getModuleConfig();
        assertNotNull(moduleConfig);
       
        // For now, the path will be null if the ActionMapping was created on its own (as opposed to from a
        // WrapperModuleConfig, which knows the path).
        assertNull(mapping.getPath());
View Full Code Here

            Object model = modelDriven.getModel();
            if (model != null) {
                HttpServletRequest req = ServletActionContext.getRequest();
                Struts1Factory strutsFactory = new Struts1Factory(configuration);
                ActionMapping mapping = strutsFactory.createActionMapping(invocation.getProxy().getConfig());
                ModuleConfig moduleConfig = strutsFactory.createModuleConfig(invocation.getProxy().getConfig().getPackageName());
                req.setAttribute(Globals.MODULE_KEY, moduleConfig);
                req.setAttribute(Globals.MESSAGES_KEY, new WrapperMessageResources((TextProvider)invocation.getAction()));
               
                mapping.setAttribute(modelDriven.getScopeKey());
               
View Full Code Here

            if ((this.src != null) || (this.srcKey != null)
                || (this.pageKey != null)) {
                throwImgTagSrcException();
            }

            ModuleConfig config =
                ModuleUtils.getInstance().getModuleConfig(this.module,
                    (HttpServletRequest) pageContext.getRequest(),
                    pageContext.getServletContext());

            HttpServletRequest request =
                (HttpServletRequest) pageContext.getRequest();
            String pageValue = this.page;

            if (!srcDefaultReference(config)) {
                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)) {
                throwImgTagSrcException();
            }

            ModuleConfig config =
                ModuleUtils.getInstance().getModuleConfig(this.module,
                    (HttpServletRequest) pageContext.getRequest(),
                    pageContext.getServletContext());

            HttpServletRequest request =
View Full Code Here

     */
    protected String renderJavascript()
        throws JspException {
        StringBuffer results = new StringBuffer();

        ModuleConfig config =
            TagUtils.getInstance().getModuleConfig(pageContext);
        ValidatorResources resources =
            (ValidatorResources) pageContext.getAttribute(
              ValidatorPlugIn.VALIDATOR_KEY
                + config.getPrefix(), PageContext.APPLICATION_SCOPE);

        if (resources == null) {
            throw new JspException(
                "ValidatorResources not found in application scope under key \""
                + ValidatorPlugIn.VALIDATOR_KEY + config.getPrefix() + "\"");
        }

        Locale locale =
            TagUtils.getInstance().getUserLocale(this.pageContext, null);

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.