Package org.apache.struts.action

Examples of org.apache.struts.action.ActionForm


        ActionServlet servlet) {
        if (config == null) {
            return (null);
        }

        ActionForm instance = null;

        // Create and return a new form bean instance
        try {
            instance = config.createActionForm(servlet);
View Full Code Here


            obj = getDynaActionFormClass().newInstance();
        } else {
            obj = formBeanClass().newInstance();
        }

        ActionForm form = null;

        if (obj instanceof ActionForm) {
            form = (ActionForm) obj;
        } else {
            form = new BeanValidatorForm(obj);
        }

        form.setServlet(servlet);

        if (form instanceof DynaBean
            && ((DynaBean) form).getDynaClass() instanceof MutableDynaClass) {
            DynaBean dynaBean = (DynaBean) form;
            MutableDynaClass dynaClass =
View Full Code Here

        if (attribute == null) {
            return (null);
        }

        // Look up the existing form bean, if any
        ActionForm instance;

        if ("request".equals(mapping.getScope())) {
            instance = (ActionForm) this.request.getAttribute(attribute);
        } else {
            instance = (ActionForm) this.session.getAttribute(attribute);
View Full Code Here

            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);
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 an unexpected error
     */
    public boolean execute(ActionContext actionCtx)
        throws Exception {
        // Is there a form bean for this request?
        ActionForm actionForm = actionCtx.getActionForm();

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

View Full Code Here

     * @return TRUE if processing should halt
     * @throws Exception on any error
     */
    public boolean execute(ActionContext actionContext)
        throws Exception {
        ActionForm form = findOrCreateForm(actionContext);

        if (isEmpty(getToKey())) {
            throw new IllegalStateException("Property 'toKey' must be defined.");
        }

View Full Code Here

        } catch (ClassCastException e) {
            throw new IllegalStateException("ActionContext [" + ctx + "]"
                + " must be subclass of ActionContextBase");
        }

        ActionForm form =
            context.findOrCreateActionForm(effectiveFormName, effectiveScope);

        if (form == null) {
            throw new IllegalArgumentException("No form found under scope ["
                + effectiveScope + "] and formName [" + effectiveFormName + "]");
View Full Code Here

        throws Exception {
        // Set form valid until found otherwise
        actionCtx.setFormValid(Boolean.TRUE);

        // Is there a form bean for this request?
        ActionForm actionForm = actionCtx.getActionForm();

        if (actionForm == null) {
            return false;
        }
View Full Code Here

        }

        // Does a usable form bean attribute already exist?
        String attribute = actionConfig.getAttribute();
        String scope = actionConfig.getScope();
        ActionForm instance = null;
        if ("request".equals(scope)) {
            instance = (ActionForm)
                context.getExternalContext().getRequestMap().get(attribute);
        } else if ("session".equals(scope)) {
            HttpSession session = (HttpSession)
                context.getExternalContext().getSession(true);
            instance = (ActionForm)
                context.getExternalContext().getSessionMap().get(attribute);
        }
        if (instance != null) {
            if (fbConfig.getDynamic()) {
                String className =
                    ((DynaBean) instance).getDynaClass().getName();
                if (className.equals(fbConfig.getName())) {
                    if (log.isDebugEnabled()) {
                        log.debug
                            (" Recycling existing DynaActionForm instance " +
                             "of type '" + className + "'");
                    }
                    return;
                }
            } else {
                try {
                    Class configClass =
                        RequestUtils.applicationClass(fbConfig.getType());
                    if (configClass.isAssignableFrom(instance.getClass())) {
                        if (log.isDebugEnabled()) {
                            log.debug
                                (" Recycling existing ActionForm instance " +
                                 "of class '" + instance.getClass().getName()
                                 + "'");
                        }
                        return;
                    }
                } catch (Throwable t) {
                    throw new IllegalArgumentException
                        ("Cannot load form bean class '" +
                         fbConfig.getType() + "'");
                }
            }
        }

        // Create a new form bean instance
        if (fbConfig.getDynamic()) {
            try {
                DynaActionFormClass dynaClass =
                    DynaActionFormClass.createDynaActionFormClass(fbConfig);
                instance = (ActionForm) dynaClass.newInstance();
                if (log.isDebugEnabled()) {
                    log.debug
                        (" Creating new DynaActionForm instance " +
                         "of type '" + fbConfig.getType() + "'");
                    log.trace(" --> " + instance);
                }
            } catch (Throwable t) {
                throw new IllegalArgumentException
                    ("Cannot create form bean of type '" +
                     fbConfig.getType() + "'");
            }
        } else {
            try {
                instance = (ActionForm)
                    RequestUtils.applicationInstance(fbConfig.getType());
                if (log.isDebugEnabled()) {
                    log.debug
                        (" Creating new ActionForm instance " +
                         "of type '" + fbConfig.getType() + "'");
                    log.trace(" --> " + instance);
                }
            } catch (Throwable t) {
                throw new IllegalArgumentException
                    ("Cannot create form bean of class '" +
                     fbConfig.getType() + "'");
            }
        }

        // Configure and cache the form bean instance in the correct scope
        ActionServlet servlet = (ActionServlet)
            context.getExternalContext().getApplicationMap().get
            (Globals.ACTION_SERVLET_KEY);
        instance.setServlet(servlet);
        if ("request".equals(scope)) {
            context.getExternalContext().getRequestMap().put
                (attribute, instance);
        } else if ("session".equals(scope)) {
            context.getExternalContext().getSessionMap().put
View Full Code Here

TOP

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

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.