Handling portlet preferences on the client
The client side programming model can read, modify, and save portlet preferences on the client.
The interface...
ibm.portal.portlet.PortletPreferences...JavaScript mirrors its server side counterpart...
javax.portlet.PortletPreferences...as closely as possible.
The following code sample retrieves and read the portlet preferences on the client:
<script> function <%=namespace%>_handleLoadPortletPreferences(portletWindow, status, portletPrefs) { if (status==ibm.portal.portlet.PortletWindow.STATUS_OK) { portletWindow.setAttribute("preferences", portletPrefs); alert("Preferences.getValue()\n"+portletPrefs.getValue("test")); var prefs = portletPrefs.getMap(); var mapStr = "Preferences.getMap()\number of preferences: "+prefs.length + "\n"; for (var i=0; i<prefs.length; i++) { mapStr += i+" - "+prefs[i].name+" - "+prefs[i].values+" - "+prefs[i].readonly + "\n"; } alert(mapStr); } else { alert("error loading feed"); } } <%=namespace%>_portletWindow = new ibm.portal.portlet.PortletWindow("<%=portletWindowID%>"); <%=namespace%>_portletWindow.getPortletPreferences(<%=namespace%>_handleLoadPortletPreferences); </script>
Parent topic
The client side portlet programming model
Related tasks
Getting started with the client side programming model for portlets
Change portlet mode and window state on the client side
JavaScript namespacing - observing good practice
Related information
http://www.ibm.com/developerworks/websphere/library/specs/0608_wp6javadoc.html