PortletPreferences in WAS porltet container

The Edit mode lets users personalize a portlet using portlet preferences. URLAddressability stores the portlet preferences in a cookie scoped by the window identifier so that you can store the preferences with any HTTP client that supports cookies. For more information about the preferences cookie, see the WebSphere Application Server Information Center

I wanted to try this so i created a simple HelloWorldPortlet like this

public class HelloWorldPortlet extends javax.portlet.GenericPortlet {
public void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException {
// Set the MIME type for the render response
response.setContentType(request.getResponseContentType());
response.getWriter().println("Inside HelloWorldPortlet.doView()");
}
public void doEdit(RenderRequest request, RenderResponse response) throws PortletException, IOException {
response.setContentType(request.getResponseContentType());
response.getWriter().println("Inside HelloWorldPortlet.doEdit()");
}
protected void doHelp(RenderRequest request, RenderResponse response) throws PortletException, IOException {
response.setContentType(request.getResponseContentType());
response.getWriter().println("Inside HelloWorldPortlet.doHelp()");
}
public void processAction(ActionRequest request, ActionResponse response) throws PortletException, java.io.IOException {
String actionName = request.getParameter("action");
if(actionName.equals("setpreference")){
request.getPreferences().setValue("testPreference", "testValue");
request.getPreferences().store();
}
}
}


In the processAction() method i am checking value of action request parameter. If the value is setprefence i am setting a prefence with name equal to testPreference and value equal to testValue.

I tried accessing the portlet by going to http://localhost:9081/helloworldportlet/HelloWorldPortlet/window/ver=1.0/action?action=setpreference URL and this is what i could see in the firebug


No comments: