Package org.springframework.webflow.execution

Examples of org.springframework.webflow.execution.RequestContext


    final Execution exec = Executions.getCurrent();
    if ("currentUser".equals(name) && exec != null) {
      return Executions.getCurrent().getUserPrincipal();
    }
   
    RequestContext flowctx = (RequestContext) exec.getAttribute(RequestContextELResolver.REQUEST_CONTEXT_VARIABLE_NAME)
    if (flowctx == null) {
      final Component target = (Component) ZkFlowContextManager.getSelf(exec);
      if (target != null) {
        if (exec.getAttribute(IN_GETTING_FLOW_CTX) != null) { //avoid endless loop
          return null;
        }
        ZKProxy.getProxy().setAttribute(exec, IN_GETTING_FLOW_CTX, Boolean.TRUE);
        try {
          flowctx = (RequestContext) target.getAttributeOrFellow(RequestContextELResolver.REQUEST_CONTEXT_VARIABLE_NAME, true); //recursive
        } finally {
          ZKProxy.getProxy().removeAttribute(exec, IN_GETTING_FLOW_CTX);
        }
      }
    }
    if (flowctx != null) {
      //check special EL variables
      if ("flowScope".equals(name)) {
        return flowctx.getFlowScope();
      } else if ("viewScope".equals(name)) {
        return flowctx.getViewScope();
      } else if ("requestScope".equals(name)) {
        return flowctx.getRequestScope();
      } else if ("flshScope".equals(name)) {
        return flowctx.getFlashScope();
      } else if ("conversationScope".equals(name)) {
        return flowctx.getConversationScope();
      } else if ("requestParameters".equals(name)) {
        return flowctx.getRequestParameters();
      } else if ("currentEvent".equals(name)) {
        return flowctx.getCurrentEvent();
      } else if ("currentUser".equals(name)) {
        return Executions.getCurrent().getUserPrincipal();
      } else if ("messageContext".equals(name)) {
        return flowctx.getMessageContext();
      } else if ("resourceBundle".equals(name)) {
        return flowctx.getActiveFlow().getApplicationContext();
        //throw new UiException("Unsupported variable: "+name);
      } else if ("flowRequestContext".equals(name)) {
        return flowctx;
      } else if ("flowExecutionContext".equals(name)) {
        return flowctx.getFlowExecutionContext();
      } else if ("flowExceutionUrl".equals(name)) {
        return flowctx.getFlowExecutionUrl();
      } else if ("externalContext".equals(name)) {
        return flowctx.getExternalContext();
      }
      //check requestScope
      final MutableAttributeMap requestScope = flowctx.getRequestScope();
      if (requestScope.contains(name)) {
        return requestScope.get(name);
      }
      //check flashScope
      final MutableAttributeMap flashScope = flowctx.getFlashScope();
      if (flashScope.contains(name)) {
        return flashScope.get(name);
      }
      //check viewScope
      final MutableAttributeMap viewScope = flowctx.getViewScope();
      if (viewScope.contains(name)) {
        return viewScope.get(name);
      }
      //check flowScope
      final MutableAttributeMap flowScope = flowctx.getFlowScope();
      if (flowScope.contains(name)) {
        return flowScope.get(name);
      }
      //check conversationScope
      final MutableAttributeMap conversationScope = flowctx.getConversationScope();
      if (conversationScope.contains(name)) {
        return conversationScope.get(name);
      }
    }
    return null;
View Full Code Here


      final Map pageMap = new HashMap();
      for(int j = 0; j < fragments.length; ++j) {
        replaceFragment(fragments[j], fragmentMap, pageMap);
      }
    } else { //has error message
      final RequestContext requestContext = (RequestContext) model.get(RequestContextELResolver.REQUEST_CONTEXT_VARIABLE_NAME);
      if (requestContext != null) {
        final MessageContext msgctx = requestContext.getMessageContext();
        if (msgctx != null) {
          final Message[] errors =
              msgctx.getMessagesByCriteria(new ErrorMessageCriteria());
          if (errors.length > 0) {
            //store new flow context into page
            ZkFlowContextManager.storeFlowContext(exec);

            final Map fragmentMap = prepareDesktopFragmentMap();
            //check the special fragment "messages"
            if (fragmentMap.containsKey("messages")) {
              requestContext.getFlashScope().put("errors", errors);
              replaceFragment("messages", fragmentMap, new HashMap());
            } else {
              //TODO ZK 3.6 use "throw new WrongValuesException(WrongValueException[])"
              final Message msg = errors[0];
              Component comp = null;
              final Object source = msg.getSource();
              if (source instanceof Component) {
                comp = (Component) source;
              } else if (source instanceof String) {
                comp  = (Component) ZkFlowContextManager.getSelf(exec).getAttribute((String)source, false);
              }
              if (comp != null) {
                //cannot throw out exception here, or the flow state will out of sync
                //save in executution and throw it later in ZkFlowHandlerAdapter.handl()
                ZkFlowContextManager.setWrongValueException(exec, new WrongValueException(comp, msg.getText()));
              } else {
                requestContext.getViewScope().put("errors", errors);
                requestContext.getExternalContext().requestFlowExecutionRedirect();
              }
            }
          }
        }
      }
View Full Code Here

    putContextFactory(RequestContext.class, new ZkRequestContextELContextFactory());
  }

  private static class ZkRequestContextELContextFactory implements ELContextFactory {
    public ELContext getELContext(Object target) {
      final RequestContext context = (RequestContext) target;
      final List resolvers = new ArrayList();
      resolvers.add(new RequestContextELResolver(context));
      resolvers.add(new FlowResourceELResolver(context));
      resolvers.add(new ImplicitFlowVariableELResolver(context));
      resolvers.add(new ScopeSearchingELResolver(context));
View Full Code Here

    if (self != null) {
      final DataBinder binder = (DataBinder) self.getAttributeOrFellow("binder", true);
      if (binder != null) {
        final Collection bindings = binder.getAllBindings();
        if (!bindings.isEmpty()) {
          final RequestContext srcRequestContext =
            ZkFlowContextManager.getFlowRequestContext(exec);
          if (srcRequestContext != null) {
            if (logger.isDebugEnabled()) {
              logger.debug("Setting up view->model mappings");
            }
View Full Code Here

  public ServletMvcView(org.springframework.web.servlet.View view, RequestContext context) {
    super(view, context);
  }

  protected void doRender(Map model) throws Exception {
    RequestContext context = getRequestContext();
    ExternalContext externalContext = context.getExternalContext();
    HttpServletRequest request = (HttpServletRequest) externalContext.getNativeRequest();
    HttpServletResponse response = (HttpServletResponse) externalContext.getNativeResponse();
    request.setAttribute(org.springframework.web.servlet.support.RequestContext.WEB_APPLICATION_CONTEXT_ATTRIBUTE,
        context.getActiveFlow().getApplicationContext());
    getView().render(model, request, response);
  }
View Full Code Here

  public PortletMvcView(org.springframework.web.servlet.View view, RequestContext context) {
    super(view, context);
  }

  protected void doRender(Map model) throws Exception {
    RequestContext context = getRequestContext();
    ExternalContext externalContext = context.getExternalContext();
    View view = getView();
    PortletContext portletContext = (PortletContext) externalContext.getNativeContext();
    RenderRequest request = (RenderRequest) externalContext.getNativeRequest();
    RenderResponse response = (RenderResponse) externalContext.getNativeResponse();
    if (response.getContentType() == null) {
      // No Portlet content type specified yet -> use the view-determined type.
      // (The Portlet spec requires the content type to be set on the RenderResponse)
      String contentType = view.getContentType();
      if (contentType != null) {
        response.setContentType(contentType);
      }
    }
    request.setAttribute(ViewRendererServlet.VIEW_ATTRIBUTE, view);
    request.setAttribute(ViewRendererServlet.MODEL_ATTRIBUTE, model);
    request.setAttribute(org.springframework.web.servlet.support.RequestContext.WEB_APPLICATION_CONTEXT_ATTRIBUTE,
        context.getActiveFlow().getApplicationContext());
    portletContext.getRequestDispatcher(DispatcherPortlet.DEFAULT_VIEW_RENDERER_URL).include(request, response);
  }
View Full Code Here

      this.delegate = delegate;
    }

    public Object getProperty(Map context, Object target, Object name) throws OgnlException {
      String property = name.toString();
      RequestContext requestContext = (RequestContext) target;
      if (property.equals("flowRequestContext")) {
        return requestContext;
      }
      if (property.equals("currentUser")) {
        return requestContext.getExternalContext().getCurrentUser();
      }
      if (property.equals("resourceBundle")) {
        return requestContext.getActiveFlow().getApplicationContext();
      }
      if (requestContext.getRequestScope().contains(property)) {
        return requestContext.getRequestScope().get(property);
      } else if (requestContext.getFlashScope().contains(property)) {
        return requestContext.getFlashScope().get(property);
      } else if (requestContext.inViewState() && requestContext.getViewScope().contains(property)) {
        return requestContext.getViewScope().get(property);
      } else if (requestContext.getFlowScope().contains(property)) {
        return requestContext.getFlowScope().get(property);
      } else if (requestContext.getConversationScope().contains(property)) {
        return requestContext.getConversationScope().get(property);
      }
      BeanFactory bf = getBeanFactory(requestContext);
      if (bf.containsBean(property)) {
        return bf.getBean(property);
      }
View Full Code Here

* @author Jeremy Grelle
*/
public class FlowAjaxTilesView extends AjaxTilesView {

  protected String[] getRenderFragments(Map model, HttpServletRequest request, HttpServletResponse response) {
    RequestContext context = RequestContextHolder.getRequestContext();
    if (context == null) {
      return super.getRenderFragments(model, request, response);
    } else {
      String[] fragments = (String[]) context.getFlashScope().get(View.RENDER_FRAGMENTS_ATTRIBUTE);
      if (fragments == null) {
        return super.getRenderFragments(model, request, response);
      }
      return fragments;
    }
View Full Code Here

      return delegate.getProperty(context, target, name);
    }

    public void setProperty(Map context, Object target, Object name, Object value) throws OgnlException {
      String property = name.toString();
      RequestContext requestContext = (RequestContext) target;
      if (property.equals("flowRequestContext")) {
        throw new OgnlException("The 'flowRequestContext' variable is not writeable");
      }
      if (property.equals("currentUser")) {
        throw new OgnlException("The 'currentUser' variable is not writeable");
      }
      if (property.equals("resourceBundle")) {
        throw new OgnlException("The 'resourceBundle' variable is not writeable");
      }
      if (requestContext.getRequestScope().contains(property)) {
        requestContext.getRequestScope().put(property, value);
      } else if (requestContext.getFlashScope().contains(property)) {
        requestContext.getFlashScope().put(property, value);
      } else if (requestContext.inViewState() && requestContext.getViewScope().contains(property)) {
        requestContext.getViewScope().put(property, value);
      } else if (requestContext.getFlowScope().contains(property)) {
        requestContext.getFlowScope().put(property, value);
      } else if (requestContext.getConversationScope().contains(property)) {
        requestContext.getConversationScope().put(property, value);
      } else {
        delegate.setProperty(context, target, name, value);
      }
    }
View Full Code Here

      return viewPath;
    }
  }

  private UIViewRoot restoreFlowPortletView(FacesContext facesContext, String resourcePath) {
    RequestContext context = RequestContextHolder.getRequestContext();
    ViewRootHolder holder = (ViewRootHolder) context.getFlashScope().get(ViewRootHolder.VIEW_ROOT_HOLDER_KEY);
    if (holder != null && holder.getViewRoot().getViewId().equals(resourcePath)) {
      return holder.getViewRoot();
    } else {
      return delegate.restoreView(facesContext, resourcePath);
    }
View Full Code Here

TOP

Related Classes of org.springframework.webflow.execution.RequestContext

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.