コード例 #1
0
  /**
   * Retrieves post metadata for the quickfinder component with the given id and if a callback
   * method has been configured, invokes that callback method.
   *
   * @param form form instance containing the model data
   * @param request http request object being handled
   * @param quickfinderId id for the quickfinder component that triggered the lookup we are
   *     returning from
   */
  protected void invokeQuickfinderCallback(
      UifFormBase form, final HttpServletRequest request, final String quickfinderId) {
    String callbackMethodToCall =
        (String)
            form.getViewPostMetadata()
                .getComponentPostData(
                    quickfinderId, UifConstants.PostMetadata.QUICKFINDER_CALLBACK_METHOD_TO_CALL);
    MethodInvokerConfig callbackMethod =
        (MethodInvokerConfig)
            form.getViewPostMetadata()
                .getComponentPostData(
                    quickfinderId, UifConstants.PostMetadata.QUICKFINDER_CALLBACK_METHOD);

    if (StringUtils.isBlank(callbackMethodToCall) && (callbackMethod == null)) {
      return;
    }

    if (callbackMethod == null) {
      callbackMethod = new MethodInvokerConfig();
    }

    // get additional parameters to be passed to the callback method
    Map<String, String> callbackContext =
        (Map<String, String>)
            form.getViewPostMetadata()
                .getComponentPostData(
                    quickfinderId, UifConstants.PostMetadata.QUICKFINDER_CALLBACK_CONTEXT);

    // if target class or object not set, use view helper service
    if ((callbackMethod.getTargetClass() == null) && (callbackMethod.getTargetObject() == null)) {
      callbackMethod.setTargetObject(form.getViewHelperService());
    }

    callbackMethod.setTargetMethod(callbackMethodToCall);

    Object[] arguments = new Object[3];
    arguments[0] = form;
    arguments[1] = quickfinderId;
    arguments[2] = callbackContext;
    callbackMethod.setArguments(arguments);

    final MethodInvokerConfig methodToInvoke = callbackMethod;

    Runnable runnable =
        new Runnable() {
          @Override
          public void run() {
            try {
              methodToInvoke.prepare();
              methodToInvoke.invoke();
            } catch (Exception e) {
              throw new RuntimeException(
                  "Error invoking callback method for quickfinder: " + quickfinderId, e);
            }
          }
        };

    ViewLifecycle.encapsulateLifecycle(
        form.getView(), form, form.getViewPostMetadata(), null, request, runnable);
  }
コード例 #2
0
  /**
   * Handles the refresh call by checking the request parameters and delegating out to helper
   * methods.
   *
   * <p>{@inheritDoc}
   */
  @Override
  public ModelAndView refresh(UifFormBase form) {
    HttpServletRequest request = form.getRequest();

    if (request.getParameterMap().containsKey(UifParameters.MESSAGE_TO_DISPLAY)) {
      String messageToDisplay = request.getParameter(UifParameters.MESSAGE_TO_DISPLAY);

      if (StringUtils.isNotBlank(messageToDisplay)) {
        GlobalVariables.getMessageMap()
            .putErrorForSectionId(KRADConstants.GLOBAL_ERRORS, messageToDisplay);
      }
    }

    if (request.getParameterMap().containsKey(UifParameters.REFRESH_STATUS)) {
      String refreshStatus = request.getParameter(UifParameters.REFRESH_STATUS);

      // if the return URL reported an error, do not continue with the refresh call
      if (UifConstants.RefreshStatus.ERROR.equals(refreshStatus)) {
        return getModelAndViewService().getModelAndView(form);
      }
    }

    String refreshCallerType = "";
    if (request.getParameterMap().containsKey(KRADConstants.REFRESH_CALLER_TYPE)) {
      refreshCallerType = request.getParameter(KRADConstants.REFRESH_CALLER_TYPE);
    }

    if (StringUtils.equals(refreshCallerType, UifConstants.RefreshCallerTypes.MULTI_VALUE_LOOKUP)) {
      processMultiValueReturn(form, request);
    }

    if (request.getParameterMap().containsKey(KRADConstants.REFERENCES_TO_REFRESH)) {
      final String referencesToRefresh = request.getParameter(KRADConstants.REFERENCES_TO_REFRESH);

      Runnable runnable =
          new Runnable() {
            @Override
            public void run() {
              ViewLifecycle.getHelper().refreshReferences(referencesToRefresh);
            }
          };

      ViewLifecycle.encapsulateLifecycle(
          form.getView(), form, form.getViewPostMetadata(), null, request, runnable);
    }

    if (request.getParameterMap().containsKey(UifParameters.QUICKFINDER_ID)) {
      String quickfinderId = request.getParameter(UifParameters.QUICKFINDER_ID);

      setFocusJumpFromQuickfinder(form, quickfinderId);

      invokeQuickfinderCallback(form, request, quickfinderId);
    }

    return getModelAndViewService().getModelAndView(form);
  }
コード例 #3
0
 private void changeTheme(UifFormBase form) {
   String theme = ((KradSampleAppForm) form).getThemeName();
   if (theme != null) {
     ViewTheme newTheme =
         (ViewTheme) (KRADServiceLocatorWeb.getDataDictionaryService().getDictionaryBean(theme));
     if (newTheme != null) {
       form.getView().setTheme(newTheme);
     }
   }
 }
コード例 #4
0
 /**
  * Changes the view to readOnly and returns.
  *
  * @param uifForm
  * @param result
  * @param request
  * @param response
  * @return readOnly View
  */
 @RequestMapping(method = RequestMethod.POST, params = "methodToCall=makeReadOnly")
 public ModelAndView makeReadOnly(
     @ModelAttribute("KualiForm") UifFormBase uifForm,
     BindingResult result,
     HttpServletRequest request,
     HttpServletResponse response) {
   // set View to readOnly
   uifForm.getView().setReadOnly(true);
   return getUIFModelAndView(uifForm);
 }
コード例 #5
0
  /**
   * Handles the return from a multi-value lookup, processing any select line values and invoking
   * the configured view helper service to create the lines for those values in the model
   * collection.
   *
   * <p>There are two supported strategies for returning the selected lines. One, if the lookup view
   * and the caller are within the same application container, Springs input flash map is used. If
   * however, the lookup view is outside the caller, then just a standard request parameter is used.
   *
   * @param form form instance containing the model data
   * @param request http request object being handled
   */
  protected void processMultiValueReturn(final UifFormBase form, HttpServletRequest request) {
    final String lookupCollectionId = request.getParameter(UifParameters.LOOKUP_COLLECTION_ID);

    final String lookupCollectionName = request.getParameter(UifParameters.LOOKUP_COLLECTION_NAME);
    if (StringUtils.isBlank(lookupCollectionName)) {
      throw new RuntimeException(
          "Lookup collection name is required for processing multi-value lookup results");
    }

    final String multiValueReturnFields =
        request.getParameter(UifParameters.MULIT_VALUE_RETURN_FILEDS);
    String selectedLineValuesParam = request.getParameter(UifParameters.SELECTED_LINE_VALUES);

    String flashMapSelectedLineValues = "";
    if (RequestContextUtils.getInputFlashMap(request) != null) {
      flashMapSelectedLineValues =
          (String)
              RequestContextUtils.getInputFlashMap(request).get(UifParameters.SELECTED_LINE_VALUES);
    }

    if (!StringUtils.isBlank(flashMapSelectedLineValues)) {
      selectedLineValuesParam = flashMapSelectedLineValues;
    }

    final String selectedLineValues = selectedLineValuesParam;

    Runnable runnable =
        new Runnable() {
          @Override
          public void run() {
            // invoked view helper to populate the collection from lookup results
            ViewLifecycle.getHelper()
                .processMultipleValueLookupResults(
                    form,
                    lookupCollectionId,
                    lookupCollectionName,
                    multiValueReturnFields,
                    selectedLineValues);
          }
        };

    ViewLifecycle.encapsulateLifecycle(
        form.getView(), form, form.getViewPostMetadata(), null, request, runnable);
  }