@Override public void store() throws IOException, ValidatorException { _portletPreferences.store(); }
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 class ConfigurationActionImpl implements ConfigurationAction { public void processAction(PortletConfig config, ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { String portletResource = ParamUtil.getString(actionRequest, "portletResource"); PortletPreferences prefs = PortletPreferencesFactoryUtil.getPortletSetup(actionRequest, portletResource); //Read, validate, and then set form parameters as portlet preferences prefs.store(); SessionMessages.add(actionRequest, portletConfig.getPortletName() + ".doConfigure"); } public String render(PortletConfig config, RenderRequest renderRequest, RenderResponse renderResponse) throws Exception { return "/configuration.jsp"; } }
/** * 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();
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();
@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); } }
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 + "]"); } }
/** * Save the prefs */ public void processPreferencesAction(ActionRequest request, ActionResponse actionResponse) throws PortletException, IOException { PortletPreferences prefs = request.getPreferences(); PreferencesHelper.requestParamsToPreferences(request); prefs.store(); actionResponse.setPortletMode(PortletMode.VIEW); }
/** * Save the prefs */ public void processPreferencesAction(ActionRequest request, ActionResponse actionResponse) throws PortletException, IOException { PortletPreferences prefs = request.getPreferences(); PreferencesHelper.requestParamsToPreferences(request); prefs.store(); actionResponse.setPortletMode(PortletMode.VIEW); }
public static void removeAndStoreSelection( List<String> assetEntryUuids, PortletPreferences portletPreferences) throws Exception { if (assetEntryUuids.isEmpty()) { return; } String[] assetEntryXmls = portletPreferences.getValues( "assetEntryXml", new String[0]); List<String> assetEntryXmlsList = ListUtil.fromArray(assetEntryXmls); Iterator<String> itr = assetEntryXmlsList.iterator(); while (itr.hasNext()) { String assetEntryXml = itr.next(); Document document = SAXReaderUtil.read(assetEntryXml); Element rootElement = document.getRootElement(); String assetEntryUuid = rootElement.elementText("asset-entry-uuid"); if (assetEntryUuids.contains(assetEntryUuid)) { itr.remove(); } } portletPreferences.setValues( "assetEntryXml", assetEntryXmlsList.toArray(new String[assetEntryXmlsList.size()])); portletPreferences.store(); }
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); }
@RequestMapping(params = "action=updateConfiguration") public void saveConfiguration( ActionRequest request, ActionResponse response, @ModelAttribute("form") SqlQueryConfigForm form, BindingResult errors, @RequestParam(value = "Save", required = false) String save) throws PortletModeException, IOException, ValidatorException, ReadOnlyException { if (StringUtils.isNotBlank(save)) { PortletPreferences prefs = request.getPreferences(); prefs.setValue( SqlQueryPortletController.DATASOURCE_BEAN_NAME_PARAM_NAME, form.getDataSource()); prefs.setValue(SqlQueryPortletController.SQL_QUERY_PARAM_NAME, form.getSqlQuery()); prefs.setValue(SqlQueryPortletController.VIEW_PARAM_NAME, form.getViewName()); prefs.setValue(SqlQueryPortletController.PREF_CACHE_NAME, form.getCacheName()); prefs.store(); } response.setPortletMode(PortletMode.VIEW); }
/** * save submitted value * * @see javax.portlet.GenericPortlet#processActions * */ public void processAction(ActionRequest request, ActionResponse actionResponse) throws PortletException, IOException { String location = request.getParameter( "location" ); String mapHeight = request.getParameter( "mapheight" ); String apiKey = request.getParameter( "apikey" ); PortletPreferences preferences = request.getPreferences(); if ( location != null ) preferences.setValue( "Location", location ); if ( mapHeight != null ) preferences.setValue( "MapHeight", mapHeight ); if ( apiKey != null ) preferences.setValue( "APIKey", apiKey ); preferences.store(); }
/** * save submitted value * * @see javax.portlet.GenericPortlet#processActions * */ public void processAction(ActionRequest request, ActionResponse actionResponse) throws PortletException, IOException { String location = request.getParameter( "location" ); String mapHeight = request.getParameter( "mapheight" ); String apiKey = request.getParameter( "apikey" ); PortletPreferences preferences = request.getPreferences(); if ( location != null ) preferences.setValue( "Location", location ); if ( mapHeight != null ) preferences.setValue( "MapHeight", mapHeight ); if ( apiKey != null ) preferences.setValue( "APIKey", apiKey ); preferences.store(); }
preferences.store();
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); }