WebSphere Portal, Express Beta Version 6.1
Operating systems: i5/OS, Linux,Windows


 

Handling portlet preferences on the client

One of the most useful aspects of the client side programming model is the ability to 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. For the full description of the JavaScript interfaces refer to the public API documentation.

The following code sample shows how you can retrieve 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: Using the client side programming model for portlets Related tasks
Getting started with the client side programming model for portlets Changing portlet mode and window state on the client side JavaScript namespacing - observing good practice
Library | Support | Terms of use |