Example usage for com.liferay.portal.kernel.template TemplateVariableGroup TemplateVariableGroup

List of usage examples for com.liferay.portal.kernel.template TemplateVariableGroup TemplateVariableGroup

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.template TemplateVariableGroup TemplateVariableGroup.

Prototype

public TemplateVariableGroup(String label) 

Source Link

Usage

From source file:com.liferay.dynamic.data.lists.web.internal.template.DDLDisplayTemplateHandler.java

License:Open Source License

protected TemplateVariableGroup getDDLUtilVariablesTemplateVariableGroups() {

    TemplateVariableGroup ddlUtilTemplateVariableGroup = new TemplateVariableGroup("data-list-util");

    ddlUtilTemplateVariableGroup.addVariable("data-list-display-template-helper",
            DDLDisplayTemplateHelper.class, "ddlDisplayTemplateHelper", null);

    return ddlUtilTemplateVariableGroup;
}

From source file:com.liferay.dynamic.data.lists.web.internal.template.DDLDisplayTemplateHandler.java

License:Open Source License

protected TemplateVariableGroup getDDLVariablesTemplateVariableGroups() {
    TemplateVariableGroup templateVariableGroup = new TemplateVariableGroup("data-list-variables");

    templateVariableGroup.addVariable("data-definition-id", null, DDLConstants.RESERVED_DDM_STRUCTURE_ID);
    templateVariableGroup.addVariable("data-list-description", String.class,
            DDLConstants.RESERVED_RECORD_SET_DESCRIPTION);
    templateVariableGroup.addVariable("data-list-id", null, DDLConstants.RESERVED_RECORD_SET_ID);
    templateVariableGroup.addVariable("data-list-name", String.class, DDLConstants.RESERVED_RECORD_SET_NAME);
    templateVariableGroup.addCollectionVariable("data-list-records", List.class, "records", "record",
            DDLRecord.class, "cur_record", null);
    templateVariableGroup.addVariable("template-id", null, DDLConstants.RESERVED_DDM_TEMPLATE_ID);

    return templateVariableGroup;
}

From source file:com.liferay.dynamic.data.mapping.template.BaseDDMTemplateHandler.java

License:Open Source License

protected TemplateVariableGroup getGeneralVariablesTemplateVariableGroup() {
    TemplateVariableGroup templateVariableGroup = new TemplateVariableGroup("general-variables");

    templateVariableGroup.addVariable("device", Device.class, "device");
    templateVariableGroup.addVariable("portal-instance", Company.class, "company");
    templateVariableGroup.addVariable("portal-instance-id", null, "companyId");
    templateVariableGroup.addVariable("site-id", null, "groupId");
    templateVariableGroup.addVariable("view-mode", String.class, "viewMode");

    return templateVariableGroup;
}

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;
    }//from w  w w .  j av  a 2 s. co  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;
}

From source file:com.liferay.dynamic.data.mapping.template.BaseDDMTemplateHandler.java

License:Open Source License

protected TemplateVariableGroup getUtilTemplateVariableGroup() {
    TemplateVariableGroup templateVariableGroup = new TemplateVariableGroup("util");

    templateVariableGroup.addVariable("permission-checker", PermissionChecker.class, "permissionChecker");
    templateVariableGroup.addVariable("random-namespace", String.class, "randomNamespace");
    templateVariableGroup.addVariable("templates-path", String.class, "templatesPath");

    return templateVariableGroup;
}

From source file:com.liferay.portlet.display.template.internal.PortletDisplayTemplateImpl.java

License:Open Source License

@Override
public Map<String, TemplateVariableGroup> getTemplateVariableGroups(String language) {

    Map<String, TemplateVariableGroup> templateVariableGroups = new LinkedHashMap<>();

    TemplateVariableGroup fieldsTemplateVariableGroup = new TemplateVariableGroup("fields");

    fieldsTemplateVariableGroup.addCollectionVariable("entries", List.class,
            PortletDisplayTemplateConstants.ENTRIES, "entries-item", null, "curEntry", null);
    fieldsTemplateVariableGroup.addVariable("entry", null, PortletDisplayTemplateConstants.ENTRY);

    templateVariableGroups.put("fields", fieldsTemplateVariableGroup);

    TemplateVariableGroup generalVariablesTemplateVariableGroup = new TemplateVariableGroup(
            "general-variables");

    generalVariablesTemplateVariableGroup.addVariable("current-url", String.class,
            PortletDisplayTemplateConstants.CURRENT_URL);
    generalVariablesTemplateVariableGroup.addVariable("locale", Locale.class,
            PortletDisplayTemplateConstants.LOCALE);
    generalVariablesTemplateVariableGroup.addVariable("portlet-preferences", Map.class,
            PortletDisplayTemplateConstants.PORTLET_PREFERENCES);
    generalVariablesTemplateVariableGroup.addVariable("template-id", null,
            PortletDisplayTemplateConstants.TEMPLATE_ID);
    generalVariablesTemplateVariableGroup.addVariable("theme-display", ThemeDisplay.class,
            PortletDisplayTemplateConstants.THEME_DISPLAY);

    templateVariableGroups.put("general-variables", generalVariablesTemplateVariableGroup);

    TemplateVariableGroup utilTemplateVariableGroup = new TemplateVariableGroup("util");

    utilTemplateVariableGroup.addVariable("http-request", HttpServletRequest.class,
            PortletDisplayTemplateConstants.REQUEST);

    if (language.equals(TemplateConstants.LANG_TYPE_VM)) {
        utilTemplateVariableGroup.addVariable("liferay-taglib", VelocityTaglib.class,
                PortletDisplayTemplateConstants.TAGLIB_LIFERAY);
    }/*from   w w  w. jav a  2 s. co  m*/

    utilTemplateVariableGroup.addVariable("render-request", RenderRequest.class,
            PortletDisplayTemplateConstants.RENDER_REQUEST);
    utilTemplateVariableGroup.addVariable("render-response", RenderResponse.class,
            PortletDisplayTemplateConstants.RENDER_RESPONSE);

    templateVariableGroups.put("util", utilTemplateVariableGroup);

    return templateVariableGroups;
}

From source file:com.liferay.site.navigation.menu.web.internal.portlet.template.SiteNavigationMenuPortletDisplayTemplateHandler.java

License:Open Source License

protected TemplateVariableGroup getUtilTemplateVariableGroup() {
    TemplateVariableGroup templateVariableGroup = new TemplateVariableGroup("navigation-util");

    templateVariableGroup.addVariable("navigation-item", NavItem.class, "navItem");

    return templateVariableGroup;
}