Esempio n. 1
0
  /**
   * Set the values of the form widget
   *
   * @param tenantID the tenantID
   * @param formWidget the widget
   * @param evaluatedExpressions
   * @param context the context including the URL parameters
   * @throws FormNotFoundException
   * @throws FormServiceProviderNotFoundException
   * @throws SessionTimeoutException
   * @throws IOException
   * @throws FileTooBigException
   * @throws FormInitializationException
   */
  public void setFormWidgetValues(
      final long tenantID,
      final FormWidget formWidget,
      final Map<String, Serializable> evaluatedExpressions,
      final Map<String, Object> context)
      throws FormNotFoundException, FormServiceProviderNotFoundException, SessionTimeoutException,
          IOException, FileTooBigException, FormInitializationException {
    final String widgetId = formWidget.getId();
    final FormServiceProvider formServiceProvider =
        FormServiceProviderFactory.getFormServiceProvider(tenantID);
    final Locale locale = (Locale) context.get(FormServiceProviderUtil.LOCALE);
    formWidget.setLabel(
        getStringValue(
            evaluatedExpressions.get(widgetId + EXPRESSION_KEY_SEPARATOR + WIDGET_LABEL)));
    formWidget.setTitle(
        getStringValue(
            evaluatedExpressions.get(widgetId + EXPRESSION_KEY_SEPARATOR + WIDGET_TITLE)));
    if (formWidget.getSubtitle() != null) {
      formWidget
          .getSubtitle()
          .setLabel(
              getStringValue(
                  evaluatedExpressions.get(widgetId + EXPRESSION_KEY_SEPARATOR + WIDGET_SUBTITLE)));
    }
    formWidget.setPopupTooltip(
        getStringValue(
            evaluatedExpressions.get(widgetId + EXPRESSION_KEY_SEPARATOR + WIDGET_TOOLTIP)));
    formWidget.setDisplayCondition(
        getDisplayCondition(
            formWidget.getDisplayConditionExpression(),
            evaluatedExpressions.get(
                widgetId + EXPRESSION_KEY_SEPARATOR + WIDGET_DISPLAY_CONDITION)));

    final Object value = getFormWidgetInitialValues(formWidget, evaluatedExpressions);
    if (formWidget.getType().name().startsWith("FILE")
        || formWidget.getType().equals(WidgetType.IMAGE) && formWidget.isDisplayAttachmentImage()) {
      final String filePaths = formWidget.getFilePaths();
      if (filePaths != null) {
        final FormFieldValue fileFieldValue = new FormFieldValue(filePaths, File.class.getName());
        formWidget.setInitialFieldValue(fileFieldValue);
      } else {
        formWidget.setInitialFieldValue(
            formServiceProvider.getAttachmentFormFieldValue(value, context));
      }
    } else if (!formWidget.getType().name().startsWith("BUTTON")) {
      // convert the value object returned into a FormFieldValue object.
      formWidget.setInitialFieldValue(getFieldValue(value, formWidget, locale));
      // set the available values list from a groovy expression for listboxes, radiobutton groups,
      // checkbox groups...
      setFormWidgetAvailableValues(formWidget, evaluatedExpressions);
    }
  }
Esempio n. 2
0
 private Map<String, Serializable> resolveDisplayExpressions(
     final List<FormWidget> widgets,
     final Map<String, Object> context,
     final FormServiceProvider formServiceProvider)
     throws FormNotFoundException, SessionTimeoutException, FileTooBigException, IOException,
         FormInitializationException {
   final Map<String, Serializable> resolvedExpressions =
       formServiceProvider.resolveExpressions(new DisplayExpressions(widgets).asList(), context);
   return resolvedExpressions != null ? resolvedExpressions : new HashMap<String, Serializable>();
 }
Esempio n. 3
0
  /**
   * set the widget values of a form page
   *
   * @param tenantID the tenant ID
   * @param widgets the widgets of the page
   * @param context the context including the URL parameters
   * @throws FormServiceProviderNotFoundException
   * @throws FormNotFoundException
   * @throws SessionTimeoutException
   * @throws IOException
   * @throws FileTooBigException
   * @throws FormInitializationException
   */
  public void setFormWidgetsValues(
      final long tenantID, final List<FormWidget> widgets, final Map<String, Object> context)
      throws FormNotFoundException, FormServiceProviderNotFoundException, SessionTimeoutException,
          IOException, FileTooBigException, FormInitializationException {
    final FormServiceProvider formServiceProvider =
        FormServiceProviderFactory.getFormServiceProvider(tenantID);

    final Map<String, Serializable> evaluatedDisplayExpressions =
        resolveDisplayExpressions(widgets, context, formServiceProvider);
    final Map<String, Serializable> evaluatedExpressions =
        formServiceProvider.resolveExpressions(
            getExpressionsToEvaluation(widgets, evaluatedDisplayExpressions, context), context);
    evaluatedExpressions.putAll(evaluatedDisplayExpressions);

    for (final FormWidget formWidget : widgets) {
      setFormWidgetValues(tenantID, formWidget, evaluatedExpressions, context);
      setTablesParams(formWidget, evaluatedExpressions, context);
    }
  }