Package org.apache.struts.config

Examples of org.apache.struts.config.ActionConfig


        // Process ActionConfig extensions.
        ActionConfig[] actionConfigs = config.findActionConfigs();

        for (int i = 0; i < actionConfigs.length; i++) {
            ActionConfig actionConfig = actionConfigs[i];

            processActionConfigExtension(actionConfig, config);
        }

        for (int i = 0; i < actionConfigs.length; i++) {
            ActionConfig actionConfig = actionConfigs[i];

            // Verify that required fields are all present for the forward
            // configs
            ForwardConfig[] forwards = actionConfig.findForwardConfigs();

            for (int j = 0; j < forwards.length; j++) {
                ForwardConfig forward = forwards[j];

                if (forward.getPath() == null) {
                    handleValueRequiredException("path", forward.getName(),
                        "action forward");
                }
            }

            // ... and the exception configs
            ExceptionConfig[] exceptions = actionConfig.findExceptionConfigs();

            for (int j = 0; j < exceptions.length; j++) {
                ExceptionConfig exception = exceptions[j];

                if (exception.getKey() == null) {
View Full Code Here


            // Nothing to do, then
            return actionConfig;
        }

        // Make sure that this config is of the right class
        ActionConfig baseConfig = moduleConfig.findActionConfig(ancestor);

        if (baseConfig == null) {
            throw new UnavailableException("Unable to find "
                + "action config for '" + ancestor + "' to extend.");
        }

        // Was our actionConfig's class overridden already?
        if (actionConfig.getClass().equals(ActionMapping.class)) {
            // Ensure that our config is using the correct class
            if (!baseConfig.getClass().equals(actionConfig.getClass())) {
                // Replace the config with an instance of the correct class
                ActionConfig newActionConfig = null;
                String baseConfigClassName = baseConfig.getClass().getName();

                try {
                    newActionConfig =
                        (ActionConfig) RequestUtils.applicationInstance(baseConfigClassName);

                    // copy the values
                    BeanUtils.copyProperties(newActionConfig, actionConfig);

                    // copy the forward and exception configs, too
                    ForwardConfig[] forwards =
                        actionConfig.findForwardConfigs();

                    for (int i = 0; i < forwards.length; i++) {
                        newActionConfig.addForwardConfig(forwards[i]);
                    }

                    ExceptionConfig[] exceptions =
                        actionConfig.findExceptionConfigs();

                    for (int i = 0; i < exceptions.length; i++) {
                        newActionConfig.addExceptionConfig(exceptions[i]);
                    }
                } catch (Exception e) {
                    handleCreationException(baseConfigClassName, e);
                }
View Full Code Here

     * otherwise return <code>null</code>. </p>
     *
     * @param path Path of the action configuration to return
     */
    public ActionConfig findActionConfig(String path) {
        ActionConfig config = (ActionConfig) actionConfigs.get(path);

        // If a direct match cannot be found, try to match action configs
        // containing wildcard patterns only if a matcher exists.
        if ((config == null) && (matcher != null)) {
            config = matcher.match(path);
View Full Code Here

     * @throws Exception on any error
     */
    public boolean execute(ActionContext actionCtx)
        throws Exception {
        // Is there a form bean associated with this ActionConfig?
        ActionConfig actionConfig = actionCtx.getActionConfig();
        String name = actionConfig.getName();

        if (name == null) {
            actionCtx.setActionForm(null);

            return (false);
        }

        if (LOG.isTraceEnabled()) {
            LOG.trace("Look up form-bean " + name);
        }

        // Look up the corresponding FormBeanConfig (if any)
        FormBeanConfig formBeanConfig =
            actionConfig.getModuleConfig().findFormBeanConfig(name);

        if (formBeanConfig == null) {
            LOG.warn("No FormBeanConfig found in module "
                + actionConfig.getModuleConfig().getPrefix() + " under name "
                + name);
            actionCtx.setActionForm(null);

            return (false);
        }

        Map scope = actionCtx.getScope(actionConfig.getScope());

        ActionForm instance;

        instance = (ActionForm) scope.get(actionConfig.getAttribute());

        // Can we recycle the existing instance (if any)?
        if (!formBeanConfig.canReuse(instance)) {
            instance = formBeanConfig.createActionForm(actionCtx);
        }

        // TODO: Remove ServletActionContext when ActionForm no longer
        //  directly depends on ActionServlet
        if (actionCtx instanceof ServletActionContext) {
            // The servlet property of ActionForm is transient, so
            // ActionForms which are restored from a serialized state
            // need to have their servlet restored.
            ServletActionContext sac = (ServletActionContext) actionCtx;

            instance.setServlet(sac.getActionServlet());
        }

        actionCtx.setActionForm(instance);

        scope.put(actionConfig.getAttribute(), instance);

        return (false);
    }
View Full Code Here

        if (action == null) {
            return (false);
        }

        ActionConfig actionConfig = actionCtx.getActionConfig();
        ActionForm actionForm = actionCtx.getActionForm();

        // Execute the Action for this request, caching returned ActionForward
        ForwardConfig forwardConfig =
            execute(actionCtx, action, actionConfig, actionForm);
View Full Code Here

     * @throws Exception on any error
     */
    public boolean execute(ActionContext actionCtx)
        throws Exception {
        // Acquire configuration objects that we need
        ActionConfig actionConfig = actionCtx.getActionConfig();

        // Cache an include uri if found
        String include = actionConfig.getInclude();

        if (include != null) {
            if (LOG.isDebugEnabled()) {
                LOG.debug("Including " + include);
            }
View Full Code Here

            return (false);
        }

        // Look up the class name for the desired Action
        ActionConfig actionConfig = actionCtx.getActionConfig();
        String type = actionConfig.getType();

        if (type == null) {
            LOG.trace("no type for " + actionConfig.getPath());

            return (false);
        }

        // Create (if necessary) and cache an Action instance
View Full Code Here

        if (actionForm == null) {
            return (false);
        }

        // Reset the form bean property values
        ActionConfig actionConfig = actionCtx.getActionConfig();

        reset(actionCtx, actionConfig, actionForm);

        populate(actionCtx, actionConfig, actionForm);
View Full Code Here

        if ((valid != null) && valid.booleanValue()) {
            return (false);
        }

        // Acquire configuration objects that we need
        ActionConfig actionConfig = actionCtx.getActionConfig();
        ModuleConfig moduleConfig = actionConfig.getModuleConfig();

        // Cache an ForwardConfig back to our input page
        ForwardConfig forwardConfig;
        String input = actionConfig.getInput();

        if (moduleConfig.getControllerConfig().getInputForward()) {
            if (LOG.isTraceEnabled()) {
                LOG.trace("Finding ForwardConfig for '" + input + "'");
            }

            forwardConfig = actionConfig.findForwardConfig(input);

            if (forwardConfig == null) {
                forwardConfig = moduleConfig.findForwardConfig(input);
            }
        } else {
View Full Code Here

        throws IllegalAccessException, InstantiationException {
        String effectiveFormName;
        String effectiveScope;

        if (!(isEmpty(this.getActionPath()))) {
            ActionConfig actionConfig =
                context.getModuleConfig().findActionConfig(this.getActionPath());

            if (actionConfig == null) {
                throw new IllegalArgumentException(
                    "No ActionConfig found for path " + this.getActionPath());
            }

            effectiveFormName = actionConfig.getName();
            effectiveScope = actionConfig.getScope();
        } else {
            effectiveFormName = this.getFormName();
            effectiveScope = this.getScope();
        }
View Full Code Here

TOP

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

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.