Preserve Portlet Window Minimize State In Liferay

Sample describes how to save portlet window minimize state pro user&portlet in Liferay 6.1.20, extend following classes

1.
User window portlet minimize action triggers preferences update, search “preserve portlet window minimize state” in: com.liferay.portal.action.UpdateLayoutActionExtended.java

...
layoutTypePortlet.resetModes();
layoutTypePortlet.resetStates();
...
PortletPreferences preferences =
      PortletPreferencesFactoryUtil.getLayoutPortletSetup(layout, portletId);
      layoutTypePortlet.setStateMin(preferences.getValue("portlet-minimaze-flag", ""));
...
else if (cmd.equals("minimize")) {
...
PortletPreferences preferences = PortletPreferencesLocalServiceUtil.getPreferences(layout.getCompanyId(), userId, PortletKeys.PREFS_OWNER_TYPE_USER, layout.getPlid(),portletId);

if (layoutTypePortlet.getStateMin().isEmpty())
{
    preferences.setValue(AnyConstants.PREFERENCES_CUSTOM_VALUE_MINIMIZE_FLAG, "");
}
else
{
    preferences.setValue(AnyConstants.PREFERENCES_CUSTOM_VALUE_MINIMIZE_FLAG, WindowState.MINIMIZED.toString());
}

2.
preferences updates windowState in: com.liferay.portal.action.RenderPortletActionExtended.java

...
if (ajaxId != null) {
      response.setHeader("Ajax-ID", ajaxId);
    }
...
PortletPreferences preferences = PortletPreferencesLocalServiceUtil.getPreferences(
layout.getCompanyId(), themeDisplay.getUserId(), PortletKeys.PREFS_OWNER_TYPE_USER, layout.getPlid(), portletId);

if (preferences.getMap().size() > 0)
{
    String windowStateString = preferences.getValue(AnyConstants.PREFERENCES_CUSTOM_VALUE_MINIMIZE_FLAG, "");
    if (windowStateString != "")
    {
        WindowState windowState =
            WindowStateFactory.getWindowState(windowStateString);
        PortalUtil.updateWindowState(
            portletId, user, layout, windowState, request);
      }
    }
}

3.
preferences updates windowState in: com.liferay.portlet.layoutconfiguration.util.RuntimePortletImplExtended.java

// similar as in RenderPortletAction


Download sample: PreservePortletWindowMinimizeStateInLiferaySample

Requirement Engineering, Business Analysis, Agile, Analysis and Design with UML, Java/J2EE, Liferay, Javascript, Embedded C++, MDD, Executable UML, Project Management


© 2017 JULIUSURBAN.NET