Example usage for com.liferay.portal.kernel.template TemplateVariableDefinition getName

List of usage examples for com.liferay.portal.kernel.template TemplateVariableDefinition getName

Introduction

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

Prototype

public String getName() 

Source Link

Usage

From source file:com.liferay.dynamic.data.mapping.internal.util.DDMTemplateHelperImpl.java

License:Open Source License

@Override
public String getAutocompleteJSON(HttpServletRequest request, String language) throws Exception {

    JSONObject jsonObject = _jsonFactory.createJSONObject();

    JSONObject typesJSONObject = _jsonFactory.createJSONObject();
    JSONObject variablesJSONObject = _jsonFactory.createJSONObject();

    for (TemplateVariableDefinition templateVariableDefinition : getAutocompleteTemplateVariableDefinitions(
            request, language)) {//ww  w. j ava  2  s. c  om

        Class<?> clazz = templateVariableDefinition.getClazz();

        if (clazz == null) {
            variablesJSONObject.put(templateVariableDefinition.getName(), StringPool.BLANK);
        } else {
            if (!typesJSONObject.has(clazz.getName())) {
                typesJSONObject.put(clazz.getName(), getAutocompleteClassJSONObject(clazz));
            }

            variablesJSONObject.put(templateVariableDefinition.getName(),
                    getAutocompleteVariableJSONObject(clazz));
        }
    }

    jsonObject.put("types", typesJSONObject);
    jsonObject.put("variables", variablesJSONObject);

    return jsonObject.toString();
}

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

License:Open Source License

protected void prepareTemplate(Template template, TemplateVariableDefinition templateVariableDefinition,
        String language) {/*from w  ww. j  a  v  a 2s  . c o m*/

    template.put("dataType", templateVariableDefinition.getDataType());
    template.put("help", templateVariableDefinition.getHelp());
    template.put("label", templateVariableDefinition.getLabel());
    template.put("language", language);
    template.put("name", templateVariableDefinition.getName());
    template.put("repeatable", templateVariableDefinition.isRepeatable());
}