Package org.apache.struts.config

Examples of org.apache.struts.config.ForwardConfig


        ModuleConfig config = mapping.getModuleConfig();
        if (config == null) {
            config = new ModuleConfigImpl("");
            mapping.setModuleConfig(config);
        }
        ForwardConfig forwardConfig = config.findForwardConfig(name);
        if (forwardConfig == null) {
            config.addForwardConfig(new ActionForward(name, path, false));
        } else {
            forwardConfig.setPath(path);
        }
    }
View Full Code Here


        ActionConfig actionConfig =
            (ActionConfig)request.getAttribute(Globals.MAPPING_KEY);

        // NOTE: ActionConfig.findForwardConfig only searches local forwards
        ForwardConfig fc = null;
        if(actionConfig != null)
        {
            fc = actionConfig.findForwardConfig(forward);

            // No ActionConfig forward?
            // Find the ForwardConfig in the global-forwards.
            if(fc == null)
            {
                fc = moduleConfig.findForwardConfig(forward);

                // ok, give up
                if (fc == null)
                {
                    return null;
                }
            }
        }

        StringBuffer url = new StringBuffer();
        if (fc.getPath().startsWith("/"))
        {
            url.append(request.getContextPath());
            url.append(RequestUtils.forwardURL(request, fc, moduleConfig));
        }
        else
        {
            url.append(fc.getPath());
        }
        return url.toString();
    }
View Full Code Here

            context.get(getActionConfigKey());
        ActionForm actionForm = (ActionForm)
            context.get(getActionFormKey());

        // Execute the Action for this request, caching returned ActionForward
        ForwardConfig forwardConfig =
            execute(context, action, actionConfig, actionForm);
        context.put(getForwardConfigKey(), forwardConfig);

        return (false);
View Full Code Here

     * otherwise, log error messages and return <code>false</code>.</p>
     */
    protected boolean verifyForwardConfigs() {

        boolean ok = true;
        ForwardConfig fcs[] = config.findForwardConfigs();
        for (int i = 0; i < fcs.length; i++) {
            String path = fcs[i].getPath();
            if (path == null) {
                log(servlet.getInternal().getMessage
                    ("verifyForwardConfigs.missing",
View Full Code Here

        // Calculate the appropriate URL
        StringBuffer url = new StringBuffer();
        HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
        if (forward != null) {
            ForwardConfig forwardConfig = moduleConfig.findForwardConfig(forward);
            if (forwardConfig == null) {
                throw new MalformedURLException(messages.getMessage("computeURL.forward", forward));
            }
            if (forwardConfig.getRedirect()) {
                redirect = true;
            }
            if (forwardConfig.getPath().startsWith("/")) {
                url.append(request.getContextPath());
                url.append(RequestUtils.forwardURL(request, forwardConfig, moduleConfig));
            } else {
                url.append(forwardConfig.getPath());
            }
        } else if (href != null) {
            url.append(href);
        } else if (action != null) {
            url.append(instance.getActionMappingURL(action, module, pageContext, false));
View Full Code Here

     *
     * @param name Logical name of the forwarding instance to be returned
     */
    public ActionForward findForward(String name) {

        ForwardConfig config = findForwardConfig(name);
        if (config == null) {
            config = getModuleConfig().findForwardConfig(name);
        }
        return ((ActionForward) config);

View Full Code Here

     * is returned.</p>
     */
    public String[] findForwards() {

        ArrayList results = new ArrayList();
        ForwardConfig fcs[] = findForwardConfigs();
        for (int i = 0; i < fcs.length; i++) {
            results.add(fcs[i].getName());
        }
        return ((String[]) results.toArray(new String[results.size()]));

View Full Code Here

        ActionConfig actionConfig = (ActionConfig)
            context.get(getActionConfigKey());
        ModuleConfig moduleConfig = actionConfig.getModuleConfig();

        // Cache an ForwardConfig back to our input page
        ForwardConfig forwardConfig = null;
        String input = actionConfig.getInput();
        if (moduleConfig.getControllerConfig().getInputForward()) {
            if (log.isTraceEnabled()) {
                log.trace("Finding ForwardConfig for '" + input + "'");
            }
View Full Code Here

     * that we're processing in "include" mode.
     */
    public boolean execute(Context context) throws Exception {

        // Is there a Tiles Definition to be processed?
        ForwardConfig forwardConfig = (ForwardConfig)
                                      context.get(getForwardConfigKey());
        if (forwardConfig == null || forwardConfig.getPath() == null)
        {
            log.debug("No forwardConfig or no path, so pass to next command.");
            return (false);
        }

        ServletWebContext swcontext = (ServletWebContext) context;

        ComponentDefinition definition = null;
        try
        {
            definition = TilesUtil.getDefinition(forwardConfig.getPath(),
                    swcontext.getRequest(),
                    swcontext.getContext());
        }
        catch (FactoryNotFoundException ex)
        {
            // this is not a serious error, so log at low priority
            log.debug("Tiles DefinitionFactory not found, so pass to next command.");
            return false;
        }

        // Do we do a forward (original behavior) or an include ?
        boolean doInclude = false;
        ComponentContext tileContext = null;

        // Get current tile context if any.
        // If context exists, we will do an include
        tileContext = ComponentContext.getContext(swcontext.getRequest());
        doInclude = (tileContext != null);

        // Controller associated to a definition, if any
        Controller controller = null;

        // Computed uri to include
        String uri = null;

        if (definition != null)
        {
            // We have a "forward config" definition.
            // We use it to complete missing attribute in context.
            // We also get uri, controller.
            uri = definition.getPath();
            controller = definition.getOrCreateController();

            if (tileContext == null) {
                tileContext =
                        new ComponentContext(definition.getAttributes());
                ComponentContext.setContext(tileContext, swcontext.getRequest());

            } else {
                tileContext.addMissing(definition.getAttributes());
            }
        }

        // Process definition set in Action, if any.  This may override the
        // values for uri or controller found using the ForwardConfig, and
        // may augment the tileContext with additional attributes.
        // :FIXME: the class DefinitionsUtil is deprecated, but I can't find
        // the intended alternative to use.
        definition = DefinitionsUtil.getActionDefinition(swcontext.getRequest());
        if (definition != null) { // We have a definition.
                // We use it to complete missing attribute in context.
                // We also overload uri and controller if set in definition.
                if (definition.getPath() != null) {
                    log.debug("Override forward uri "
                              + uri
                              + " with action uri "
                              + definition.getPath());
                        uri = definition.getPath();
                }

                if (definition.getOrCreateController() != null) {
                    log.debug("Override forward controller with action controller");
                        controller = definition.getOrCreateController();
                }

                if (tileContext == null) {
                        tileContext =
                                new ComponentContext(definition.getAttributes());
                        ComponentContext.setContext(tileContext, swcontext.getRequest());
                } else {
                        tileContext.addMissing(definition.getAttributes());
                }
        }


        if (uri == null) {
            log.debug("no uri computed, so pass to next command");
            return false;
        }

        // Execute controller associated to definition, if any.
        if (controller != null) {
            log.trace("Execute controller: " + controller);
            controller.execute(
                    tileContext,
                    swcontext.getRequest(),
                    swcontext.getResponse(),
                    swcontext.getContext());
        }

        // If request comes from a previous Tile, do an include.
        // This allows to insert an action in a Tile.

        if (doInclude) {
            log.info("Tiles process complete; doInclude with " + uri);
            doInclude(swcontext, uri);
            return (true);
        } else {
            // create an "instant" forward config which can be used
            // by an AbstractPerformForward later as if our ForwardConfig
            // were the one actually returned by an executing Action
            log.info("Tiles process complete; forward to " + uri);
            // :FIXME: How do we need to coordinate the "context-relative" value
            // with other places it might be set.  For now, hardcode to true.
            context.put(getForwardConfigKey(), new ForwardConfig("tiles-chain", uri, false, true));
            return (false);
        }
    }
View Full Code Here

        // Acquire configuration objects that we need
        ActionConfig actionConfig = (ActionConfig)
                                    context.get(getActionConfigKey());
        ModuleConfig moduleConfig = actionConfig.getModuleConfig();

        ForwardConfig forwardConfig = null;
        String forward = actionConfig.getForward();
        if (forward != null) {
            forwardConfig = forward(context, moduleConfig, forward);
            if (log.isDebugEnabled()) {
                log.debug("Forwarding to " + forwardConfig);
View Full Code Here

TOP

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

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.