protected void storeWidgetInCacheAndSetCacheID( final FormCacheUtil formCacheUtil, final String formID, final String pageID, final String locale, final Date processDeployementDate, final FormWidget formWidget) { if (isExpressionDynamic(formWidget.getInitialValueExpression()) || isArrayOfExpressionsDynamic(formWidget.getInitialValueExpressionArray()) || isExpressionDynamic(formWidget.getAvailableValuesExpression()) || isListOfExpressionsDynamic(formWidget.getAvailableValues()) || isListOfListOfExpressionsDynamic(formWidget.getTableAvailableValues()) || isExpressionDynamic(formWidget.getDisplayConditionExpression())) { formWidget.setHasDynamicValue(true); } final String formWidgetCacheId = formCacheUtil.storeFormWidget(formID, pageID, locale, processDeployementDate, formWidget); formWidget.setFormWidgetCacheId(formWidgetCacheId); if (formWidget.getValidators() != null) { formWidget.setValidatorsCacheId( formCacheUtil.storeFieldValidators( formID, pageID, formWidget.getId(), locale, processDeployementDate, formWidget.getValidators())); } }
/** * 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); } }