/** * Reads a portlet preference from the portlet of the request. * * @param name * The name of the portlet preference. Cannot be * <code>null</code>. * * @return The value of the portlet preference, <code>null</code> if the * preference is not defined. */ public String getPortletPreference(String name) { PortletRequest request = getRequest(); PortletPreferences preferences = request.getPreferences(); return preferences.getValue(name, null); }
@Override protected String[] doGetValues(String key) { return _portletPreferences.getValues(key, null); }
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; }
@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); Map<String, String[]> preferencesMap = portletPreferences.getMap(); for (Map.Entry<String, String[]> entry : preferencesMap.entrySet()) { String oldName = entry.getKey(); String newName = TextFormatter.format(oldName, TextFormatter.M); portletPreferences.reset(oldName); portletPreferences.setValues(newName, entry.getValue()); } return PortletPreferencesFactoryUtil.toXML(portletPreferences); }
FacesContext facesContext = FacesContext.getCurrentInstance(); value = getPortletRequest(facesContext); FacesContext facesContext = FacesContext.getCurrentInstance(); value = getPortletResponse(facesContext); FacesContext facesContext = FacesContext.getCurrentInstance(); value = getPortletRequest(facesContext); value = new MutablePreferenceMap(portletRequest.getPreferences()); FacesContext facesContext = FacesContext.getCurrentInstance(); value = facesContext.getExternalContext().getSession(true); FacesContext facesContext = FacesContext.getCurrentInstance(); value = facesContext.getExternalContext().getSessionMap(); value = portletRequest.getPreferences(); value = portletRequest.getPreferences().getMap();
ExternalContext extCtx = facesContext.getExternalContext(); return extCtx.getRequest(); } else return extCtx.getResponse(); } else return extCtx.getRequest(); } else return ((PortletRequest) extCtx.getRequest()).getPreferences(); case portletPreferencesValues: context.setPropertyResolved(true); return ((PortletRequest) extCtx.getRequest()).getPreferences().getMap(); default: return null;
@SuppressWarnings("unchecked") private Map<String, String> getPreferencesValueMap(ExternalContext extCtx) { Map<String, String> m; PortletRequest portletRequest = (PortletRequest) extCtx.getRequest(); Enumeration<String> e = portletRequest.getPreferences().getNames(); if (e.hasMoreElements()) { m = new HashMap<String, String>(); while (e.hasMoreElements()) { String name = e.nextElement(); String value = portletRequest.getPreferences().getValue(name, null); if (value != null) { m.put(name, value); } } } else { m = Collections.emptyMap(); } return m; }
(PortletConfig) servletRequest.getAttribute(Constants.PORTLET_CONFIG); PortletSession portletSession = portletRequest.getPortletSession(false); PortletPreferences portletPreferences = portletRequest.getPreferences(); portletPreferencesValues = portletPreferences.getMap();
protected String getServantFuncName(PortletRequest request) { final PortletSession session = request.getPortletSession(); String fname = (String)session.getAttribute(FNAME_ATTRIBUTE); if (fname == null) { final PortletPreferences preferences = request.getPreferences(); fname = preferences.getValue(FNAME_ATTRIBUTE, null); if (fname != null) { session.setAttribute(FNAME_ATTRIBUTE, fname); } } return fname; }
public static String getPortletTitle( PortletPreferences portletSetup, String languageId) { if (!isUseCustomTitle(portletSetup)) { return null; } return portletSetup.getValue("portletSetupTitle_" + languageId, null); }
public String getParameter(String name) { String retVal = request.getParameter(name); if(retVal == null && name.equals("topic")) { String rootSpace = request.getPreferences().getValue("rootSpace", null); if(rootSpace != null && rootSpace.length() > 0) { if(logger.isDebugEnabled()) logger.debug("Root space [" + rootSpace + "] was getted from preferences"); retVal = rootSpace + ".WebHome"; } } return retVal; }
/** * Returns a String hashcode of the values for the portlet preferences that are configurable by * the Dynamic Skin portlet. The hashcode is generated in a repeatable fashion by calculating it * based on sorted portlet preference names. Though hashcode does not guarantee uniqueness, from * a practical perspective we'll have so few different values we can reasonably assume * preference value combinations will be unique. * * @see DynamicSkinUniqueTokenGenerator#generateToken(DynamicSkinInstanceData) */ @Override public String generateToken(final DynamicSkinInstanceData data) { final PortletPreferences preferences = data.getPortletRequest().getPreferences(); int hash = 0; // Add the list of preference names to an ordered list so we can get reliable hashcode // calculations. final Map<String, String[]> prefs = preferences.getMap(); final TreeSet<String> orderedNames = new TreeSet<String>(prefs.keySet()); final Iterator<String> iterator = orderedNames.iterator(); while (iterator.hasNext()) { final String preferenceName = iterator.next(); if (preferenceName.startsWith(DynamicRespondrSkinConstants.CONFIGURABLE_PREFIX)) { hash = hash * 31 + preferences.getValue(preferenceName, "").trim().hashCode(); } } return Integer.toString(hash); } }
private Map<String, Object> getBeans(PortletRequest req) { Map<String, Object> rslt = new HashMap<String, Object>(); // default PortletPreferences prefs = req.getPreferences(); String[] beanNames = prefs.getValues(BEANS_PREFERENCE, new String[] {}); for (String name : beanNames) { Object bean = applicationContext.getBean(name); rslt.put(name, bean); } logger.debug("Invoking with beans={}", (Object[]) beanNames); return rslt; }
prefs.store(); con = getConnection(request); StatusMessage msg = new StatusMessage("Connection made successfully.", StatusMessage.SUCCESS); response.setPortletMode(PortletMode.EDIT); return; prefs.store(); response.setPortletMode(PortletMode.EDIT); response.setRenderParameter("configPage", editAction); response.setRenderParameter(TABLE_NAME, request.getParameter(TABLE_NAME)); return; prefs.store(); response.setPortletMode(PortletMode.VIEW);
@ActionMapping public void submitSearch( ActionRequest request, ActionResponse response, @RequestParam(value = "query", required = false) String query) { // Should we request to maximize? PortletPreferences prefs = request.getPreferences(); boolean maximize = Boolean.parseBoolean( prefs.getValue(MAXIMIZE_ON_SEARCH_PREFERENCE, "true")); // default is true if (maximize) { try { response.setWindowState(WindowState.MAXIMIZED); } catch (WindowStateException e) { log.warn("Failed to set the window state to MAXIMIZED", e); } } // Forward the query parameter... if (query != null) { response.setRenderParameter("query", query); } }
/** * Create static data * @param req portlet request * @return channel runtime data */ protected ChannelStaticData getStaticData(PortletRequest req) { // retrieve channel subscribe parameters from preferences PortletPreferences prefrences=req.getPreferences(); Map channelParameters=new HashMap(); for(Enumeration e=prefrences.getNames();e.hasMoreElements();) { String parameterName=(String) e.nextElement(); if(!parameterName.startsWith(ADAPTER_PREFIX)) { channelParameters.put(parameterName,prefrences.getValue(parameterName,null)); } } ChannelStaticData staticData=new org.jasig.portal.portlets.channeladapter.ChannelStaticData(channelParameters); return staticData; }
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 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 + "]"); } }