Example usage for com.liferay.portal.kernel.model Portlet getPublicRenderParameters

List of usage examples for com.liferay.portal.kernel.model Portlet getPublicRenderParameters

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.model Portlet getPublicRenderParameters.

Prototype

public java.util.Set<PublicRenderParameter> getPublicRenderParameters();

Source Link

Document

Returns the public render parameters of the portlet.

Usage

From source file:com.liferay.portlet.configuration.web.internal.portlet.PortletConfigurationPortlet.java

License:Open Source License

public void editPublicRenderParameters(ActionRequest actionRequest, ActionResponse actionResponse)
        throws Exception {

    Portlet portlet = ActionUtil.getPortlet(actionRequest);

    PortletPreferences portletPreferences = ActionUtil.getLayoutPortletSetup(actionRequest, portlet);

    actionRequest = ActionUtil.getWrappedActionRequest(actionRequest, portletPreferences);

    Enumeration<String> enu = portletPreferences.getNames();

    while (enu.hasMoreElements()) {
        String name = enu.nextElement();

        if (name.startsWith(PublicRenderParameterConfiguration.IGNORE_PREFIX)
                || name.startsWith(PublicRenderParameterConfiguration.MAPPING_PREFIX)) {

            portletPreferences.reset(name);
        }/*from   w  ww.  jav a  2s. c  om*/
    }

    for (PublicRenderParameter publicRenderParameter : portlet.getPublicRenderParameters()) {

        String ignoreKey = PublicRenderParameterConfiguration.getIgnoreKey(publicRenderParameter);

        boolean ignoreValue = ParamUtil.getBoolean(actionRequest, ignoreKey);

        if (ignoreValue) {
            portletPreferences.setValue(ignoreKey, String.valueOf(Boolean.TRUE));
        } else {
            String mappingKey = PublicRenderParameterConfiguration.getMappingKey(publicRenderParameter);

            String mappingValue = ParamUtil.getString(actionRequest, mappingKey);

            if (Validator.isNotNull(mappingValue)) {
                portletPreferences.setValue(mappingKey, mappingValue);
            }
        }
    }

    if (SessionErrors.isEmpty(actionRequest)) {
        portletPreferences.store();
    }
}