Package org.apache.struts.action

Examples of org.apache.struts.action.ActionForm


        assertNotNull("Mapping has non-null name", mapping.getName());
        assertEquals("Mapping has correct name", "dynamic2", mapping.getName());
        assertNotNull("AppConfig has form bean " + mapping.getName(),
            moduleConfig2.findFormBeanConfig(mapping.getName()));

        ActionForm form =
            RequestUtils.createActionForm(request, mapping, moduleConfig2, null);

        assertNotNull("ActionForm returned", form);
        assertTrue("ActionForm of correct type", form instanceof DynaActionForm);
    }
View Full Code Here


        assertNotNull("Mapping has non-null name", mapping.getName());
        assertEquals("Mapping has correct name", "dynamic0", mapping.getName());
        assertNotNull("AppConfig has form bean " + mapping.getName(),
            moduleConfig.findFormBeanConfig(mapping.getName()));

        ActionForm form =
            RequestUtils.createActionForm(request, mapping, moduleConfig, null);

        assertNotNull("ActionForm returned", form);
        assertTrue("ActionForm of correct type", form instanceof DynaActionForm);
View Full Code Here

        ExceptionConfig exceptionConfig, ActionConfig actionConfig,
        ModuleConfig moduleConfig)
        throws Exception {
        // Look up the remaining properties needed for this handler
        ServletActionContext sacontext = (ServletActionContext) context;
        ActionForm actionForm = (ActionForm) sacontext.getActionForm();
        HttpServletRequest request = sacontext.getRequest();
        HttpServletResponse response = sacontext.getResponse();

        // Handle this exception
        org.apache.struts.action.ExceptionHandler handler =
View Full Code Here

    public ActionForm findOrCreateActionForm(String formName, String scopeName,
        ModuleConfig moduleConfig)
        throws IllegalAccessException, InstantiationException {
        Map scope = this.getScope(scopeName);

        ActionForm instance;
        FormBeanConfig formBeanConfig =
            moduleConfig.findFormBeanConfig(formName);

        if (formBeanConfig == null) {
            throw new IllegalArgumentException("No form config found under "
                + formName + " in module " + moduleConfig.getPrefix());
        }

        instance = (ActionForm) scope.get(formName);

        // ISSUE: Can we recycle the existing instance (if any)?
        if (instance != null) {
            getLogger().trace("Found an instance in scope " + scopeName
                + "; test for reusability");

            if (formBeanConfig.canReuse(instance)) {
                return instance;
            }
        }

        ActionForm form = formBeanConfig.createActionForm(this);

        // ISSUE: Should we check this call to put?
        scope.put(formName, form);

        return form;
View Full Code Here

                    }
                   
                    ServletContext servletContext = InternalUtils.getServletContext( request );
                    ReloadableClassHandler rch = Handlers.get( servletContext ).getReloadableClassHandler();
                    Object formBean = rch.newInstance( _outputFormBeanType );
                    ActionForm wrappedFormBean = InternalUtils.wrapFormBean( formBean );
                    addOutputForm( wrappedFormBean );
                    return wrappedFormBean;
                }
                catch ( Exception e )
                {
View Full Code Here

                {
                    assert _flowController != null// should be set in initialize()
                    Field field = _flowController.getClass().getDeclaredField( retFormMember );
                    returnFormClass = field.getType();
                    if ( ! Modifier.isPublic( field.getModifiers() ) ) field.setAccessible( true );
                    ActionForm form = InternalUtils.wrapFormBean( field.get( _flowController ) );
                   
                    if ( form != null )
                    {
                        if ( _log.isDebugEnabled() )
                        {
View Full Code Here

                                     HttpServletResponse response )
    {
        try
        {
            ActionMapping mapping = InternalUtils.getCurrentActionMapping( request );
            ActionForm form = InternalUtils.getCurrentActionForm( request );
            ActionForward fwd = fc.handleException( th, mapping, form, request, response );
            fc.getRequestProcessor().doActionForward( request, response, fwd );
            return true;
        }
        catch ( Throwable t )
View Full Code Here

        assert name != null : mapping.getPath();
        if ( name == null ) return null;

        FormBeanConfig config = moduleConfig.findFormBeanConfig( name );
        ActionForm instance;

        //
        // Create the form bean.  There's special handling for dyna-form-beans.
        //
        if ( config.getDynamic() )
        {
            try
            {
                DynaActionFormClass dynaClass = DynaActionFormClass.createDynaActionFormClass( config );
                instance = ( ActionForm ) dynaClass.newInstance();
                ( ( DynaActionForm ) instance ).initialize( mapping );

                if ( _log.isDebugEnabled() )
                {
                    _log.debug( " Creating new DynaActionForm instance " + "of type '" + config.getType() + '\'' );
                }
            }
            catch ( Exception e )
            {
                _log.error( servlet.getInternal().getMessage( "formBean", config.getType() ), e );
                return null;
            }
        }
        else
        {
            try
            {
                instance = ( ActionForm ) InternalUtils.newReloadableInstance( config.getType(), getServletContext() );

                if ( _log.isDebugEnabled() )
                {
                    _log.debug( " Creating new ActionForm instance " + "of type '" + config.getType() + '\'' );
                }
            }
            catch ( Exception e )
            {
                _log.error( servlet.getInternal().getMessage( "formBean", config.getType() ), e );
                return null;
            }
        }

        instance.setServlet( servlet );
        return instance;
    }
View Full Code Here

        // This happens when a pageflow action forwards to another pageflow,
        // whose begin action expects a form.  In this case, the form is already
        // constructed, and shouldn't be instantiated anew or populated from request
        // parameters.
        //
        ActionForm previousForm = InternalUtils.getForwardedFormBean( request, false );

        if ( previousForm != null )
        {
            //
            // If there was a forwarded form, and if this action specifies a pageflow-scoped form member,
            // set the member with this form.
            //
            if ( formMemberField != null )
            {
                try
                {
                    FlowController fc = PageFlowRequestWrapper.get( request ).getCurrentFlowController();
                    assert fc != null : "no FlowController in request " + request.getRequestURI();
                    formMemberField.set( fc, InternalUtils.unwrapFormBeanpreviousForm ) );
                }
                catch ( IllegalAccessException e )
                {
                    _log.error( "Could not access page flow member " + formMemberField.getName()
                                  + " as the form bean.", e );
                }
            }

            //
            // Return the forwarded form.
            //
            previousForm.setServlet( servlet );
            return previousForm;
        }

        //
        // First see if the previous action put a pageflow-scoped form in the request.  If so, remove it;
        // we don't want a normal request-scoped action to use this pageflow-scoped form.
        //
        String pageFlowScopedFormName = PageFlowRequestWrapper.get( request ).getPageFlowScopedFormName();
        if ( pageFlowScopedFormName != null )
        {
            request.removeAttribute( pageFlowScopedFormName );
            PageFlowRequestWrapper.get( request ).setPageFlowScopedFormName( null );
        }

        //
        // If this action specifies a pageflow-scoped form member variable, use it.
        //
        if ( formMemberField != null )
        {
            try
            {
                FlowController fc = PageFlowRequestWrapper.get( request ).getCurrentFlowController();
                ActionForm form = InternalUtils.wrapFormBean( formMemberField.get( fc ) );

                if ( form == null ) // the pageflow hasn't filled the value yet
                {
                    form = createActionForm( mapping, request );
                    form.reset( mapping, request );
                    formMemberField.set( fc, InternalUtils.unwrapFormBean( form ) );
                }

                //
                // Store the form in the right place in the request, so Struts can see it.
                // But, mark a flag so we know to remove this on the next action request -- we don't
                // want this form used by another action unless that action uses the pageflow-scoped
                // form.
                //
                String formAttrName = mapping.getAttribute();
                request.setAttribute( formAttrName, form );
                PageFlowRequestWrapper.get( request ).setPageFlowScopedFormName( formAttrName );
                return form;
            }
            catch ( IllegalAccessException e )
            {
                _log.error( "Could not access page flow member " + formMemberField.getName() + " as the form bean.", e );
            }
        }

        ActionForm bean = super.processActionForm( request, response, mapping );
        if ( bean == null )
        {
            bean = InternalUtils.createActionForm( mapping, moduleConfig, servlet, getServletContext() );
        }
View Full Code Here

        throws ServletException
    {
        //
        // If a previous action forwarded us a form, use that -- don't populate it from request parameters.
        //
        ActionForm previousForm = InternalUtils.getForwardedFormBean( request, true );

        if ( previousForm != null )
        {
            return;
        }
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.