List of usage examples for com.liferay.portal.kernel.portlet PortalPreferences setValues
public void setValues(String namespace, String key, String[] values);
From source file:com.liferay.journal.web.internal.portlet.JournalPortlet.java
License:Open Source License
public void addAddMenuFavItem(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { String ddmStructureKey = ParamUtil.getString(actionRequest, "ddmStructureKey"); PortalPreferences portalPreferences = PortletPreferencesFactoryUtil.getPortalPreferences(actionRequest); String key = JournalPortletUtil.getAddMenuFavItemKey(actionRequest, actionResponse); String[] addMenuFavItems = portalPreferences.getValues(JournalPortletKeys.JOURNAL, key, new String[0]); if (addMenuFavItems.length >= _journalWebConfiguration.maxAddMenuItems()) { hideDefaultErrorMessage(actionRequest); throw new MaxAddMenuFavItemsException(); }/*from w w w . ja va 2 s . c om*/ portalPreferences.setValues(JournalPortletKeys.JOURNAL, key, ArrayUtil.append(addMenuFavItems, ddmStructureKey)); SessionMessages.add(actionRequest, _portal.getPortletId(actionRequest) + SessionMessages.KEY_SUFFIX_REFRESH_PORTLET, JournalPortletKeys.JOURNAL); }
From source file:com.liferay.journal.web.internal.portlet.JournalPortlet.java
License:Open Source License
public void removeAddMenuFavItem(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { String ddmStructureKey = ParamUtil.getString(actionRequest, "ddmStructureKey"); PortalPreferences portalPreferences = PortletPreferencesFactoryUtil.getPortalPreferences(actionRequest); String key = JournalPortletUtil.getAddMenuFavItemKey(actionRequest, actionResponse); String[] addMenuFavItems = portalPreferences.getValues(JournalPortletKeys.JOURNAL, key); portalPreferences.setValues(JournalPortletKeys.JOURNAL, key, ArrayUtil.remove(addMenuFavItems, ddmStructureKey)); SessionMessages.add(actionRequest,/* w ww . j a v a 2s. c o m*/ _portal.getPortletId(actionRequest) + SessionMessages.KEY_SUFFIX_REFRESH_PORTLET, JournalPortletKeys.JOURNAL); }