Package org.apache.struts.action

Examples of org.apache.struts.action.ActionMapping


    // Default module -- Dynamic ActionForm with initializers
    public void testCreateActionForm4a() {
        // Retrieve an appropriately configured DynaActionForm instance
        request.setPathElements("/myapp", "/dynamic0.do", null, null);

        ActionMapping mapping =
            (ActionMapping) moduleConfig.findActionConfig("/dynamic0");

        assertNotNull("Found /dynamic0 mapping", mapping);
        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);
View Full Code Here


     */
    public String resolveAction( String actionName, Object form, HttpServletRequest request,
                                 HttpServletResponse response )
        throws Exception
    {
        ActionMapping mapping = ( ActionMapping ) getModuleConfig().findActionConfig( '/' + actionName );
       
        if ( mapping == null )
        {
            InternalUtils.throwPageFlowException( new ActionNotFoundException( actionName, this, form ), request );
        }
View Full Code Here

    {
        if ( fc != null )
        {
            try
            {
                ActionMapping mapping = InternalUtils.getCurrentActionMapping( request );
                ActionForm form = InternalUtils.getCurrentActionForm( request );
                ActionForward fwd = fc.handleException( th, mapping, form, request, response );
                processForwardConfig( request, response, fwd );
                return true;
            }
View Full Code Here

            }

            //
            // Make sure that the requested pageflow matches the pageflow for the directory.
            //
            ActionMapping beginMapping = getBeginMapping();
            if ( beginMapping != null )
            {
                String desiredType = beginMapping.getParameter();
                desiredType = desiredType.substring( desiredType.lastIndexOf( '.' ) + 1 ) + JPF_EXTENSION;
                String requestedType = InternalUtils.getDecodedServletPath( request );
                requestedType = requestedType.substring( requestedType.lastIndexOf( '/' ) + 1 );

                if ( ! requestedType.equals( desiredType ) )
View Full Code Here

        if ( forwardedForm != null )
        {
            forwardedFormClass = forwardedForm.getClass();
            List/*< ActionMapping >*/ possibleMatches = ( List ) _overloadedActions.get( path );
            ActionMapping bestMatch = null;

            //
            // Troll through the overloaded actions for the given path.  Look for the one whose form bean class is
            // exactly the class of the forwarded form; failing that, look for one that's assignable from the class
            // of the forwarded form.
            //
            for ( int i = 0; possibleMatches != null && i < possibleMatches.size(); ++i )
            {
                ActionMapping possibleMatch = ( ActionMapping ) possibleMatches.get( i );
                assert possibleMatch instanceof PageFlowActionMapping : possibleMatch.getClass();
                Class cachedFormBeanClass = ( Class ) _formBeanClasses.get( possibleMatch.getName() );

                if ( forwardedFormClass.equals( cachedFormBeanClass ) )
                {
                    bestMatch = possibleMatch;
                    break;
                }
                if ( bestMatch == null && isCorrectFormType( forwardedFormClass, possibleMatch ) )
                {
                    bestMatch = possibleMatch;
                }
            }

            if ( bestMatch != null )
            {
                request.setAttribute( Globals.MAPPING_KEY, bestMatch );

                if ( _log.isDebugEnabled() )
                {
                    _log.debug( "Found form-specific action mapping " + bestMatch.getPath() + " for " + path
                                + ", form " + forwardedFormClass.getName() );
                }

                return checkTransaction( request, response, bestMatch, path );
            }
        }

        //
        // Look for a directly-defined mapping for this path.
        //
        ActionMapping mapping = ( ActionMapping ) moduleConfig.findActionConfig( path );

        if ( mapping != null )
        {
            boolean wrongForm = false;

            //
            // We're going to bail out if there is a forwarded form and this mapping requires a different form type.
            //
            if ( forwardedForm != null )
            {
                boolean mappingHasNoFormBean = mapping.getName() == null;
                wrongForm = mappingHasNoFormBean || ! isCorrectFormType( forwardedFormClass, mapping );
            }

            if ( ! wrongForm )
            {
View Full Code Here

            // calls this method (or if a plain Struts action forwards to this forward) --
            // otherwise, the page flow should be using a Forward already.
            //
            if ( fwd instanceof PageFlowActionForward )
            {
                ActionMapping mapping = ( ActionMapping ) request.getAttribute( Globals.MAPPING_KEY );
                assert mapping != null;
                ActionForm form = InternalUtils.getFormBean( mapping, request );
                Forward pfFwd = new Forward( ( ActionForward ) fwd, servletContext );
                ActionForwardHandler handler = _handlers.getActionForwardHandler();
                fwd = handler.doForward( context, pfFwd, mapping, InternalUtils.getActionName( mapping ), null, form );
View Full Code Here

    private boolean handleException( Throwable th, FlowController fc, HttpServletRequest request,
                                     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;
        }
View Full Code Here

       
        //
        // Figure out what URI to return to, and set the original form in the request or session.
        //       
        ActionForward retFwd = prevPageInfo.getForward();
        ActionMapping prevMapping = prevPageInfo.getMapping();
       
        //
        // Restore any forms that are specified by this Forward (overwrite the original forms).
        //
        if ( retFwd instanceof Forward )
        {
            PageFlowUtils.setOutputForms( prevMapping, ( Forward ) retFwd, request, false );
            InternalUtils.addActionOutputs( ( ( Forward ) retFwd ).getActionOutputs(), request, false );
        }
       
        //
        // If the user hit the previous page directly (without going through an action), prevMapping will be null.
        //
        if ( prevMapping != null )
        {
            //
            // If the currently-posted form is of the right type, initialize the page with that (but we don't overwrite
            // the form that was set above).
            //
            if ( currentForm != null ) PageFlowUtils.setOutputForm( prevMapping, currentForm, request, false );
       
            //
            // Initialize the page with the original form it got forwarded (but we don't overwrite the form that was
            // set above).
            //
            InternalUtils.setFormInScope( prevMapping.getName(), prevPageInfo.getForm(), prevMapping, request, false );
        }
           
        //
        // If we're forwarding to a page in a different pageflow, we need to make sure the returned ActionForward has
        // the right module path, and that it has contextRelative=true.
View Full Code Here

       
        rw.setExceptionBeingHandled( ex );
       
       
        // Callback to the event reporter.
        ActionMapping originalActionMapping = actionMapping;
        _eventReporter.exceptionRaised( context, ex, originalActionMapping, form, flowController );
        long startTime = System.currentTimeMillis();
   
        //
        // Look up the ExceptionConfig that's associated with this Throwable.
View Full Code Here

        String formName = form.getName();
        jsFormName = formName;
                if(jsFormName.charAt(0) == '/') {
                    String mappingName = TagUtils.getInstance().getActionMappingName(jsFormName);
                    ActionMapping mapping = (ActionMapping) config.findActionConfig(mappingName);
                    if (mapping == null) {
                        JspException e = new JspException(messages.getMessage("formTag.mapping", mappingName));
                        pageContext.setAttribute(Globals.EXCEPTION_KEY, e, PageContext.REQUEST_SCOPE);
                        throw e;
                    }
                    jsFormName = mapping.getAttribute();
                }
       
        results.append(this.getJavascriptBegin(methods));

        for (Iterator i = actions.iterator(); i.hasNext();) {
View Full Code Here

TOP

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

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.