@Override public ModifiableSettings setValue(String key, String value) { try { _portletPreferences.setValue(key, value); } catch (ReadOnlyException roe) { _log.error( "Portlet preferences used to persist settings should never " + "be read only", roe); } return this; }
public static PortletPreferences updatePortletSetup( Layout layout, String portletId, Map<String, String> preferences) throws Exception { PortletPreferences portletSetup = PortletPreferencesFactoryUtil.getLayoutPortletSetup( layout, portletId); for (Map.Entry<String, String> entry : preferences.entrySet()) { String key = entry.getKey(); String value = entry.getValue(); portletSetup.setValue(key, value); } portletSetup.store(); return portletSetup; }
public static void updateLastPublishDate( String portletId, PortletPreferences portletPreferences, DateRange dateRange, Date lastPublishDate) { Date originalLastPublishDate = getLastPublishDate(portletPreferences); if (!isValidDateRange(dateRange, originalLastPublishDate)) { return; } if (lastPublishDate == null) { lastPublishDate = new Date(); } try { portletPreferences.setValue( _LAST_PUBLISH_DATE, String.valueOf(lastPublishDate.getTime())); portletPreferences.store(); } catch (UnsupportedOperationException uoe) { if (_log.isDebugEnabled()) { _log.debug( "Not updating the portlet setup for " + portletId + " because no setup was returned for the current page"); } } catch (Exception e) { _log.error(e, e); } }
public void setValue(String value) throws ReadOnlyException { mPreferences.setValue(mPreferenceKey, value); }
public void setValue(String value) throws ReadOnlyException { portletPreferences.setValue(name, value); }
public void setValue(String value) throws ReadOnlyException { portletPreferences.setValue(name, value); }
PortletPreferences portletSetup = PortletPreferencesFactoryUtil.getLayoutPortletSetup(layout, instanceId); Locale locale = new Locale("en", "US"); //straight to the point portletSetup.setValue("portlet-setup-title-" + LocaleUtil.toLanguageId(locale), title); portletSetup.setValue("portlet-setup-use-custom-title", "true"); portletSetup.store();
/** * Stores a Java object as JSON in a portlet preference * * @param prefs Preferences to persist to * @param key Preference key to store in * @param data Object to store as JSON */ @Override public void storeJson(PortletPreferences prefs, String key, Object data) throws IOException, ReadOnlyException, ValidatorException { final String configData = mapper.writeValueAsString(data); prefs.setValue(key, configData); prefs.store(); }
PortletPreferences portletPreference = actionRequest.getPreferences(); portletPreference.setValue("help", "me"); portletPreference.store();
@Override public void setPersistentPreference(String key,String value){ try{ request.getPreferences().setValue(key, value); } catch ( ReadOnlyException e) { Logger.getLogger(PortletDataWrapper.class.getName()).log(Level.SEVERE, null, e); } try { request.getPreferences().store(); } catch (IOException ex) { Logger.getLogger(PortletDataWrapper.class.getName()).log(Level.SEVERE, null, ex); } catch (ValidatorException ex) { Logger.getLogger(PortletDataWrapper.class.getName()).log(Level.SEVERE, null, ex); } }
protected void transformDateFieldValue( PortletPreferences portletPreferences) throws Exception { String value = GetterUtil.getString( portletPreferences.getValue(_DDM_STRUCTURE_FIELD_VALUE, null)); if (Validator.isNotNull(value)) { Date date = _oldDateFormat.parse(value); portletPreferences.setValue( _DDM_STRUCTURE_FIELD_VALUE, _newDateFormat.format(date)); } }
public void processAction(ActionRequest request, ActionResponse response) throws PortletException, IOException { String source = request.getParameter(SRC_PREF); String height = request.getParameter(HEIGHT_PREF); String width = request.getParameter(WIDTH_PREF); String maxSource = request.getParameter(MAX_SRC_PREF); String maxHeight = request.getParameter(MAX_HEIGHT_PREF); String maxWidth = request.getParameter(MAX_WIDTH_PREF); PortletPreferences prefs = request.getPreferences(); prefs.setValue(SRC_PREF, source); prefs.setValue(HEIGHT_PREF, height); prefs.setValue(WIDTH_PREF, width); prefs.setValue(MAX_SRC_PREF, maxSource); prefs.setValue(MAX_HEIGHT_PREF, maxHeight); prefs.setValue(MAX_WIDTH_PREF, maxWidth); prefs.store(); super.processAction(request, response); }
public void processAction(ActionRequest request, ActionResponse response) throws PortletException, IOException { String source = request.getParameter(SRC_PREF); String height = request.getParameter(HEIGHT_PREF); String width = request.getParameter(WIDTH_PREF); String maxSource = request.getParameter(MAX_SRC_PREF); String maxHeight = request.getParameter(MAX_HEIGHT_PREF); String maxWidth = request.getParameter(MAX_WIDTH_PREF); PortletPreferences prefs = request.getPreferences(); prefs.setValue(SRC_PREF, source); prefs.setValue(HEIGHT_PREF, height); prefs.setValue(WIDTH_PREF, width); prefs.setValue(MAX_SRC_PREF, maxSource); prefs.setValue(MAX_HEIGHT_PREF, maxHeight); prefs.setValue(MAX_WIDTH_PREF, maxWidth); prefs.store(); super.processAction(request, response); }
public void processAction(ActionRequest request, ActionResponse response) throws PortletException, IOException { String source = request.getParameter(SRC_PREF); String height = request.getParameter(HEIGHT_PREF); String width = request.getParameter(WIDTH_PREF); String maxSource = request.getParameter(MAX_SRC_PREF); String maxHeight = request.getParameter(MAX_HEIGHT_PREF); String maxWidth = request.getParameter(MAX_WIDTH_PREF); PortletPreferences prefs = request.getPreferences(); prefs.setValue(SRC_PREF, source); prefs.setValue(HEIGHT_PREF, height); prefs.setValue(WIDTH_PREF, width); prefs.setValue(MAX_SRC_PREF, maxSource); prefs.setValue(MAX_HEIGHT_PREF, maxHeight); prefs.setValue(MAX_WIDTH_PREF, maxWidth); prefs.store(); super.processAction(request, response); }
private void handleConfigForm(ActionRequest actionRequest, ActionResponse actionResponse) throws PortletException, IOException { PortletPreferences preferences = actionRequest.getPreferences(); String rootSpace = actionRequest.getParameter(ROOT_SPACE_PARAM_NAME); preferences.setValue(XWikiPortletRequest.ROOT_SPACE_PREF_NAME, rootSpace); actionResponse.setPortletMode(PortletMode.VIEW); preferences.store(); if (logger.isDebugEnabled()) { logger.debug("New root space is [" + rootSpace + "]"); } }
@Override protected String upgradePreferences( long companyId, long ownerId, int ownerType, long plid, String portletId, String xml) throws Exception { PortletPreferences portletPreferences = PortletPreferencesFactoryUtil.fromXML( companyId, ownerId, ownerType, plid, portletId, xml); String socialBookmarksDisplayStyle = portletPreferences.getValue( "socialBookmarksDisplayStyle", "menu"); if (!socialBookmarksDisplayStyle.equals("menu")) { portletPreferences.setValue( "socialBookmarksDisplayStyle", "inline"); } return PortletPreferencesFactoryUtil.toXML(portletPreferences); }
@Override protected String upgradePreferences( long companyId, long ownerId, int ownerType, long plid, String portletId, String xml) throws Exception { PortletPreferences portletPreferences = PortletPreferencesFactoryUtil.fromXML( companyId, ownerId, ownerType, plid, portletId, xml); String enableSocialBookmarks = portletPreferences.getValue( "enableSocialBookmarks", Boolean.TRUE.toString()); if (!enableSocialBookmarks.equals(Boolean.TRUE.toString())) { portletPreferences.setValue( "socialBookmarksTypes", StringPool.BLANK); } portletPreferences.reset("enableSocialBookmarks"); portletPreferences.reset("socialBookmarksDisplayPosition"); return PortletPreferencesFactoryUtil.toXML(portletPreferences); }
public void showById(ActionRequest actionRequest, ActionResponse actionResponse) throws IOException, PortletException { PortletPreferences prefs = actionRequest.getPreferences(); String id = actionRequest.getParameter("id"); if(id != null) { prefs.setValue("id", id); prefs.store(); } String mvcPath = actionRequest.getParameter("mvcPath"); // this would tell the render method to show the required JSP actionResponse.setRenderParameter("mvcPath", mvcPath); }
@Override protected String upgradePreferences( long companyId, long ownerId, int ownerType, long plid, String portletId, String xml) throws Exception { PortletPreferences portletPreferences = PortletPreferencesFactoryUtil.fromXML( companyId, ownerId, ownerType, plid, portletId, xml); String[] extensions = portletPreferences.getValues( "extensions", StringPool.EMPTY_ARRAY); if (ArrayUtil.isNotEmpty(extensions)) { portletPreferences.setValue( "extensions", StringUtil.merge(extensions)); } return PortletPreferencesFactoryUtil.toXML(portletPreferences); }
long companyId = themeDisplay.getCompanyId(); long ownerId = PortletKeys.PREFS_OWNER_ID_DEFAULT; int ownerType = PortletKeys.PREFS_OWNER_TYPE_LAYOUT; Layout layout = LayoutLocalServiceUtil.getLayout(themeDisplay.getPlid()); LayoutTypePortlet layoutTypePortlet = (LayoutTypePortlet) layout.getLayoutType(); String iframePortletId = layoutTypePortlet.addPortletId(themeDisplay.getUserId(),PortletKeys.IFRAME,"column-2",-1); PortletPreferences prefs = PortletPreferencesLocalServiceUtil.getPreferences(companyId,ownerId,ownerType,layout.getPlid(),iframePortletId); prefs.setValue("src", "http://www.google.com"); com.liferay.portal.model.PortletPreferences objPortletPref=PortletPreferencesLocalServiceUtil.updatePreferences(ownerId, ownerType, layout.getPlid(), iframePortletId, prefs); LayoutLocalServiceUtil.updateLayout(layout.getGroupId(),layout.isPrivateLayout(),layout.getLayoutId(),layout.getTypeSettings());