コード例 #1
0
  private boolean handleHelperStart() {
    Logger.log.info("Handling helper start in view: " + viewParameters.viewID);
    View view = new View();
    List producersList = viewResolver.getProducers(viewParameters.viewID);
    if (producersList.size() != 1) {
      throw new IllegalArgumentException(
          "There is not exactly one view producer for the view: " + viewParameters.viewID);
    }
    ViewComponentProducer vp = (ViewComponentProducer) producersList.get(0);

    statePreservationManager.scopeRestore();
    vp.fillComponents(view.viewroot, viewParameters, null);
    statePreservationManager.scopePreserve();
    UIOutput helperId = (UIOutput) view.viewroot.getComponent(HelperViewParameters.HELPER_ID);
    UICommand helperBinding =
        (UICommand) view.viewroot.getComponent(HelperViewParameters.POST_HELPER_BINDING);
    tsh.putTokenState(
        TOKEN_STATE_PREFIX + viewParameters.viewID + HelperViewParameters.HELPER_ID,
        helperId.getValue());
    if (helperBinding != null) {
      tsh.putTokenState(
          TOKEN_STATE_PREFIX + viewParameters.viewID + HelperViewParameters.POST_HELPER_BINDING,
          helperBinding.methodbinding);
      // Support for a ParameterList on the UICommand
      if (helperBinding.parameters != null) {
        tsh.putTokenState(
            TOKEN_STATE_PREFIX + viewParameters.viewID + POST_HELPER_BINDING_PARAMLIST,
            helperBinding.parameters);
      }
    }
    // We need to save these ViewParameters for ActionResultInterceptors
    tsh.putTokenState(
        TOKEN_STATE_PREFIX + viewParameters.viewID + POST_HELPER_ARI2_VIEWPARAMS, viewParameters);

    // Hack to know if we're in the helper
    tsh.putTokenState(IN_HELPER_INDICATOR, IN_HELPER_INDICATOR);

    String helperToolPath = bup.getBaseURL() + viewParameters.viewID + IN_HELPER_PATH;
    tsh.putTokenState(
        helperId.getValue() + Tool.HELPER_DONE_URL,
        bup.getBaseURL() + viewParameters.viewID + HELPER_FINISHED_PATH);

    try {
      response.sendRedirect(helperToolPath);
    } catch (IOException e) {
      throw UniversalRuntimeException.accumulate(
          e, "IOException when trying to redirect to helper tool");
    }

    return true;
  }
コード例 #2
0
  private boolean handleHelperDone() {
    Logger.log.info("Done handling helper in view: " + viewParameters.viewID);

    // Removing hack
    tsh.clearTokenState(IN_HELPER_INDICATOR);

    ELReference elref =
        (ELReference)
            tsh.getTokenState(
                TOKEN_STATE_PREFIX
                    + viewParameters.viewID
                    + HelperViewParameters.POST_HELPER_BINDING);
    ParameterList paramlist =
        (ParameterList)
            tsh.getTokenState(
                TOKEN_STATE_PREFIX + viewParameters.viewID + POST_HELPER_BINDING_PARAMLIST);
    statePreservationManager.scopeRestore();
    if (paramlist != null) {
      for (int i = 0; i < paramlist.size(); i++) {
        UIParameter param = (UIParameter) paramlist.get(i);
        if (param instanceof UIELBinding) {
          bma.setBeanValue(
              ((UIELBinding) param).valuebinding.value,
              beanLocator,
              ((UIELBinding) param).rvalue,
              null,
              false);
        }
      }
    }
    String methodBinding = elref == null ? null : elref.value;
    Object beanReturn = null;
    if (methodBinding != null) {
      ShellInfo shells = bma.fetchShells(methodBinding, beanLocator, true);
      beanReturn = bma.invokeBeanMethod(shells, null);
    }

    ViewParameters originParams =
        (ViewParameters)
            tsh.getTokenState(
                TOKEN_STATE_PREFIX + viewParameters.viewID + POST_HELPER_ARI2_VIEWPARAMS);

    ARIResult ariresult = ari.interpretActionResult(viewParameters, beanReturn);
    ariprocessor.interceptActionResult(ariresult, originParams, ariresult);
    String urlToRedirectTo = ViewParamUtil.getAnyFullURL(ariresult.resultingView, vsh);
    try {
      response.sendRedirect(urlToRedirectTo);
    } catch (IOException e) {
      throw UniversalRuntimeException.accumulate(e, "Error redirecting to url: " + urlToRedirectTo);
    }
    return true;
  }