Package net.sourceforge.stripes.controller

Examples of net.sourceforge.stripes.controller.ExecutionContext


            final Configuration config = StripesFilter.getConfiguration();
            final ActionResolver resolver = StripesFilter.getConfiguration().getActionResolver();
            final HttpServletRequest request = (HttpServletRequest) getPageContext().getRequest();
            final HttpServletResponse response = (HttpServletResponse) getPageContext().getResponse();
            Resolution resolution = null;
            ExecutionContext ctx = new ExecutionContext();

            // Lookup the ActionBean if we don't already have it
            if (beanNotPresent) {
                ActionBeanContext tempContext =
                        config.getActionBeanContextFactory().getContextInstance(request, response);
                tempContext.setServletContext(getPageContext().getServletContext());
                ctx.setLifecycleStage(LifecycleStage.ActionBeanResolution);
                ctx.setActionBeanContext(tempContext);

                // Run action bean resolution
                ctx.setInterceptors(config.getInterceptors(LifecycleStage.ActionBeanResolution));
                resolution = ctx.wrap( new Interceptor() {
                    public Resolution intercept(ExecutionContext ec) throws Exception {
                        ActionBean bean = resolver.getActionBean(ec.getActionBeanContext(), binding);
                        ec.setActionBean(bean);
                        return null;
                    }
                });
            }
            else {
                ctx.setActionBean(actionBean);
                ctx.setActionBeanContext(actionBean.getContext());
            }

            // Then, if and only if an event was specified, run handler resolution
            if (resolution == null && event != null && (beanNotPresent || this.alwaysExecuteEvent)) {
                ctx.setLifecycleStage(LifecycleStage.HandlerResolution);
                ctx.setInterceptors(config.getInterceptors(LifecycleStage.HandlerResolution));
                resolution = ctx.wrap( new Interceptor() {
                    public Resolution intercept(ExecutionContext ec) throws Exception {
                        ec.setHandler(resolver.getHandler(ec.getActionBean().getClass(), event));
                        ec.getActionBeanContext().setEventName(event);
                        return null;
                    }
                });
            }

            // Make the PageContext available during the validation stage so that we
            // can execute EL based expression validation
            try {
                DispatcherHelper.setPageContext(getPageContext());

                // Bind applicable request parameters to the ActionBean
                if (resolution == null && (beanNotPresent || this.validate == true)) {
                    resolution = DispatcherHelper.doBindingAndValidation(ctx, this.validate);
                }

                // Run custom validations if we're validating
                if (resolution == null && this.validate == true) {
                    String temp =  config.getBootstrapPropertyResolver().getProperty(
                                        DispatcherServlet.RUN_CUSTOM_VALIDATION_WHEN_ERRORS);
                    boolean validateWhenErrors = temp != null && Boolean.valueOf(temp);

                    resolution = DispatcherHelper.doCustomValidation(ctx, validateWhenErrors);
                }
            }
            finally {
                DispatcherHelper.setPageContext(null);
            }

            // Fill in any validation errors if they exist
            if (resolution == null && this.validate == true) {
                resolution = DispatcherHelper.handleValidationErrors(ctx);
            }

            // And (again) if an event was supplied, then run the handler
            if (resolution == null && event != null && (beanNotPresent || this.alwaysExecuteEvent)) {
                resolution = DispatcherHelper.invokeEventHandler(ctx);
            }

            DispatcherHelper.fillInValidationErrors(ctx)// just in case!

            if (resolution != null && this.executeResolution) {
                DispatcherHelper.executeResolution(ctx, resolution);
            }

            // If a name was specified, bind the ActionBean into page context
            if (getVar() != null) {
                pageContext.setAttribute(getVar(), ctx.getActionBean());
            }

            return SKIP_BODY;
        }
        catch(Exception e) {
View Full Code Here


            context.getValidationErrors().addGlobalError(error);
        else
            context.getValidationErrors().add(fieldName, error);

        // Create an ExecutionContext so that the validation errors can be filled in
        ExecutionContext exectx = new ExecutionContext();
        exectx.setActionBean(actionBean);
        exectx.setActionBeanContext(context);
        DispatcherHelper.fillInValidationErrors(exectx);

        // Forward back to referer, using the wrapped request
        return new ForwardResolution(path) {
            @Override
View Full Code Here

            context.getValidationErrors().addGlobalError(error);
        else
            context.getValidationErrors().add(fieldName, error);

        // Create an ExecutionContext so that the validation errors can be filled in
        ExecutionContext exectx = new ExecutionContext();
        exectx.setActionBean(actionBean);
        exectx.setActionBeanContext(context);
        DispatcherHelper.fillInValidationErrors(exectx);

        // Forward back to referer, using the wrapped request
        return new ForwardResolution(path) {
            @Override
View Full Code Here

            context.getValidationErrors().addGlobalError(error);
        else
            context.getValidationErrors().add(fieldName, error);

        // Create an ExecutionContext so that the validation errors can be filled in
        ExecutionContext exectx = new ExecutionContext();
        exectx.setActionBean(actionBean);
        exectx.setActionBeanContext(context);
        DispatcherHelper.fillInValidationErrors(exectx);

        // Forward back to referer, using the wrapped request
        return new ForwardResolution(path) {
            @Override
View Full Code Here

TOP

Related Classes of net.sourceforge.stripes.controller.ExecutionContext

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.