protected JSONArray getDDMFormFieldsJSONArray(DDMForm ddmForm, String script) { if (Validator.isNull(script)) { return null; } JSONArray defaultDDMFormFieldsJSONArray = null; if (ddmForm != null) { defaultDDMFormFieldsJSONArray = getDDMFormFieldsJSONArray( ddmForm.getDDMFormFields(), ddmForm.getAvailableLocales(), ddmForm.getDefaultLocale()); } try { DDMForm scriptDDMForm = DDMFormJSONDeserializerUtil.deserialize(script); return getDDMFormFieldsJSONArray( scriptDDMForm.getDDMFormFields(), scriptDDMForm.getAvailableLocales(), scriptDDMForm.getDefaultLocale()); } catch (PortalException pe) { if (_log.isWarnEnabled()) { _log.warn("Unable to deserialize script", pe); } return defaultDDMFormFieldsJSONArray; } }
protected List<DDMFormFieldValue> getDDMFormFieldValues( HttpServletRequest httpServletRequest, DDMForm ddmForm) { Map<String, DDMFormFieldValue> ddmFormFieldValuesMap = createDDMFormFieldValuesMap(httpServletRequest, ddmForm); return getDDMFormFieldValues(ddmFormFieldValuesMap, ddmForm.getDDMFormFields()); }
protected Set<String> createDefaultDDMFormFieldParameterNames(DDMForm ddmForm) { Set<String> defaultDDMFormFieldParameterNames = new TreeSet<>(); poupulateDefaultDDMFormFieldParameterNames( ddmForm.getDDMFormFields(), StringPool.BLANK, defaultDDMFormFieldParameterNames); return defaultDDMFormFieldParameterNames; }
protected void checkDDMFormFieldParameterNames( DDMForm ddmForm, Set<String> ddmFormFieldParameterNames) { if (ddmFormFieldParameterNames.isEmpty()) { ddmFormFieldParameterNames.addAll(createDefaultDDMFormFieldParameterNames(ddmForm)); return; } checkDDMFormFieldParameterNames( ddmForm.getDDMFormFields(), StringPool.BLANK, ddmFormFieldParameterNames); }
@Override public void validate(DDMForm ddmForm) throws DDMFormValidationException { validateDDMFormLocales(ddmForm); List<DDMFormField> ddmFormFields = ddmForm.getDDMFormFields(); if (ddmFormFields.isEmpty()) { throw new MustSetFieldsForForm(); } validateDDMFormFields( ddmFormFields, new HashSet<String>(), ddmForm.getAvailableLocales(), ddmForm.getDefaultLocale()); }
@Override public DDMFormLayout getDefaultDDMFormLayout(DDMForm ddmForm) { DDMFormLayout ddmFormLayout = new DDMFormLayout(); Locale defaultLocale = ddmForm.getDefaultLocale(); ddmFormLayout.setDefaultLocale(defaultLocale); ddmFormLayout.setPaginationMode(DDMFormLayout.SINGLE_PAGE_MODE); DDMFormLayoutPage ddmFormLayoutPage = new DDMFormLayoutPage(); LocalizedValue title = getDefaultDDMFormPageTitle(defaultLocale); ddmFormLayoutPage.setTitle(title); for (DDMFormField ddmFormField : ddmForm.getDDMFormFields()) { ddmFormLayoutPage.addDDMFormLayoutRow(getDefaultDDMFormLayoutRow(ddmFormField)); } ddmFormLayout.addDDMFormLayoutPage(ddmFormLayoutPage); return ddmFormLayout; }