1 Reply Latest reply on Mar 3, 2009 11:01 AM by piergiorgiolucidi

    Setting Portlet Preferences in Jboss Portal

    dynamolalit

      Hi,

      i am working on JBoss portal customization & created one portlet for Address Book management.I have requirements to set per user preferences per portlet in JBoss Portal like number of contacts per page in address book for each user.

      One way i noticed is in Edit mode of portlet,call backend to store preferences.But in my case i have two back ends- first is JBoss Portal & other is Server handling address book.Server team wants to store these preferences in Portal itself not in backend.I also noticed setting preferences in tag in portlet.xml. But i can not use this also.

      So can anyone suggest me how i can store these preferences in JBoss Portal so when user logs out & again log in,he should get his preferences again as same.Can anyone please help me how to store user preferences in JBoss Portal using JBoss preference Management after getting it from portlet.

      TIA.
      Regards,
      j lalit

        • 1. Re: Setting Portlet Preferences in Jboss Portal
          piergiorgiolucidi

          To manage preferences in your portlet you need to add preferences in your portlet.xml in this way:

          <portlet>
          <portlet-name>YourPortlet</portlet-name>
          <portlet-class>org.yourcompany.portlet.content.YourPortlet</portlet-class>
          <supports>
           <mime-type>text/html</mime-type>
           <portlet-mode>VIEW</portlet-mode>
          </supports>
          <portlet-info>
           <title>Your Portlet Title</title>
          </portlet-info>
          <portlet-preferences>
           <preference>
           <name>numberContactPerPage</name>
           <value>10</value>
           </preference>
          </portlet-preferences>
          </portlet>
          


          Then in your portlet you can use this snippet:
          public void processAction (ActionRequest request, ActionResponse
          actionResponse)
          throws PortletException, java.io.IOException {
           PortletPreferences pref = request.getPreferences();
           pref.setValue("15",request.getParameter("numberContactPerPage"));
           pref.store();
           actionResponse.setPortletMode(PortletMode.VIEW);
           actionResponse.setRenderParameters(request.getParameterMap());
          }
          


          Hope this helps.