List of usage examples for com.liferay.portal.kernel.template TemplateVariableGroup addFieldVariable
public TemplateVariableDefinition addFieldVariable(String label, Class<?> clazz, String variableName, String help, String dataType, boolean repeatable, TemplateVariableCodeHandler templateVariableCodeHandler)
From source file:com.liferay.dynamic.data.mapping.template.BaseDDMTemplateHandler.java
License:Open Source License
protected TemplateVariableGroup getStructureFieldsTemplateVariableGroup(long ddmStructureId, Locale locale) throws PortalException { if (ddmStructureId <= 0) { return null; }/* ww w . j a va 2 s. c o m*/ TemplateVariableGroup templateVariableGroup = new TemplateVariableGroup("fields"); DDMStructure ddmStructure = DDMStructureLocalServiceUtil.getStructure(ddmStructureId); DDMForm fullHierarchyDDMForm = ddmStructure.getFullHierarchyDDMForm(); Map<String, String> fieldNameVariableNameMap = new LinkedHashMap<>(); for (DDMFormField ddmFormField : fullHierarchyDDMForm.getDDMFormFields()) { fieldNameVariableNameMap.put(ddmFormField.getName(), ddmFormField.getName()); collectNestedFieldNameVariableName(ddmFormField, fieldNameVariableNameMap); } for (Entry<String, String> fieldNameVariableName : fieldNameVariableNameMap.entrySet()) { String fieldName = fieldNameVariableName.getKey(); String label = ddmStructure.getFieldLabel(fieldName, locale); String tip = ddmStructure.getFieldTip(fieldName, locale); String dataType = ddmStructure.getFieldDataType(fieldName); boolean repeatable = ddmStructure.getFieldRepeatable(fieldName); if (Validator.isNull(dataType)) { continue; } templateVariableGroup.addFieldVariable(label, getFieldVariableClass(), fieldNameVariableName.getValue(), tip, dataType, repeatable, getTemplateVariableCodeHandler()); } return templateVariableGroup; }