Package org.springframework.webflow.execution

Examples of org.springframework.webflow.execution.RequestContext


  // internal helpers

  private boolean validateModel(FacesContext facesContext, String eventId) {
    boolean isValid = true;
    RequestContext requestContext = RequestContextHolder.getRequestContext();
    Object model = getModelObject(requestContext);
    if (shouldValidate(requestContext, model, eventId)) {
      validate(requestContext, model, eventId);
      if (requestContext.getMessageContext().hasErrorMessages()) {
        isValid = false;
        if (requestContext.getExternalContext().isAjaxRequest()) {
          List fragments = new ArrayList();
          String formId = getModelExpression(requestContext).getExpressionString();
          if (facesContext.getViewRoot().findComponent(formId) != null) {
            fragments.add(formId);
          }
          if (facesContext.getViewRoot().findComponent(MESSAGES_ID) != null) {
            fragments.add(MESSAGES_ID);
          }
          if (fragments.size() > 0) {
            String[] fragmentsArray = new String[fragments.size()];
            for (int i = 0; i < fragments.size(); i++) {
              fragmentsArray[i] = (String) fragments.get(i);
            }
            requestContext.getFlashScope().put(View.RENDER_FRAGMENTS_ATTRIBUTE, fragmentsArray);
          }
        }
      }
    }
    return isValid;
View Full Code Here


     * <p>Gets rendered fragments.</p>
     *
     * <p><strong>Note</strong>: Copied from <code>FlowAjaxTilesView</code>.</p>
     */
    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

    if (!JsfUtils.isFlowRequest()) {
      return this.delegateResolver.resolveUrl(path);
    }

    try {
      RequestContext context = RequestContextHolder.getRequestContext();
      ApplicationContext flowContext = context.getActiveFlow().getApplicationContext();
      if (flowContext == null) {
        throw new IllegalStateException("A Flow ApplicationContext is required to resolve Flow View Resources");
      }

      ApplicationContext appContext = flowContext.getParent();
View Full Code Here

  public void testAny() throws Exception {
    String expression = "*";
    TransitionCriteria criterion = (TransitionCriteria) converter.convertSourceToTargetClass(expression,
        TransitionCriteria.class);
    RequestContext ctx = getRequestContext();
    assertTrue("Criterion should evaluate to true", criterion.test(ctx));
    assertSame(WildcardTransitionCriteria.INSTANCE,
        converter.convertSourceToTargetClass("*", TransitionCriteria.class));
    assertSame(WildcardTransitionCriteria.INSTANCE,
        converter.convertSourceToTargetClass("", TransitionCriteria.class));
View Full Code Here

  public void testStaticEventId() throws Exception {
    String expression = "sample";
    TransitionCriteria criterion = (TransitionCriteria) converter.convertSourceToTargetClass(expression,
        TransitionCriteria.class);
    RequestContext ctx = getRequestContext();
    assertTrue("Criterion should evaluate to true", criterion.test(ctx));
  }
View Full Code Here

  public void testTrueEvaluation() throws Exception {
    String expression = "#{flowScope.foo == 'bar'}";
    TransitionCriteria criterion = (TransitionCriteria) converter.convertSourceToTargetClass(expression,
        TransitionCriteria.class);
    RequestContext ctx = getRequestContext();
    assertTrue("Criterion should evaluate to true", criterion.test(ctx));
  }
View Full Code Here

  public void testFalseEvaluation() throws Exception {
    String expression = "#{flowScope.foo != 'bar'}";
    TransitionCriteria criterion = (TransitionCriteria) converter.convertSourceToTargetClass(expression,
        TransitionCriteria.class);
    RequestContext ctx = getRequestContext();
    assertFalse("Criterion should evaluate to false", criterion.test(ctx));
  }
View Full Code Here

        return new StaticExpression(null);
      }
    });
    TransitionCriteria criterion = (TransitionCriteria) converter.convertSourceToTargetClass("doesnt matter",
        TransitionCriteria.class);
    RequestContext ctx = getRequestContext();
    assertFalse("Criterion should evaluate to false", criterion.test(ctx));
  }
View Full Code Here

      return viewPath;
    }
  }

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

   * This resolver is only meant to be called from the Flow Execution, thus it assumes that the FacesContext will not
   * be available and creates a temporary one on the fly.
   * @return The initialized FacesContext.
   */
  private FacesContext getFacesContext() {
    RequestContext requestContext = RequestContextHolder.getRequestContext();
    Assert.notNull(requestContext, "RequestContext cannot be null - This resolver is only intended to be invoked "
        + "from an active Flow Execution.");
    FacesContext facesContext = FlowFacesContext.newInstance(requestContext, FlowLifecycle.newInstance());
    return facesContext;
  }
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.