2 Replies Latest reply on Feb 6, 2007 9:14 PM by Christopher Logan

    javax.portlet.PortletPreferences;

    Christopher Logan Newbie

      Where are the values persisted? Is it in the database or in a file somewhere in Jboss portal? Is it by user?

      For instance, in the Weather Portlet:

      PortletPreferences prefs = request.getPreferences();
      try
      {
      prefs.setValue("RssXml", RSS_URL_PREFIX + newZip);
      prefs.store();
      }
      catch(Exception e)
      {
      e.printStackTrace();
      }


      Thanks,

      Christopher

        • 1. Re: javax.portlet.PortletPreferences;
          Viet Master

          It is indeed persisted in the database, where it depends from the versions of portal. Since 2.4 it is persisted in :

          CREATE TABLE `JBP_PORTLET_STATE` (
           `PK` bigint(20) NOT NULL auto_increment,
           `PORTLET_ID` varchar(255) NOT NULL,
           `REGISTRATION_ID` bigint(20) default NULL,
           `REGISTRATION_TIME` datetime default NULL,
           `TERMINATION_TIME` datetime default NULL,
           `PARENT_PK` bigint(20) default NULL,
           PRIMARY KEY (`PK`)
          )


          CREATE TABLE `JBP_PORTLET_STATE_ENTRY` (
           `PK` bigint(20) NOT NULL auto_increment,
           `NAME` varchar(255) default NULL,
           `TYPE` int(11) NOT NULL,
           `READ_ONLY` bit(1) NOT NULL,
           `ENTRY_KEY` bigint(20) default NULL,
           PRIMARY KEY (`PK`)
          )


          CREATE TABLE `JBP_PORTLET_STATE_ENTRY_VALUE` (
           `PK` bigint(20) NOT NULL,
           `jbp_value` varchar(255) default NULL,
           `IDX` int(11) NOT NULL,
           PRIMARY KEY (`PK`,`IDX`)
          )


          Usually the state of a portlet preference set is held in one entry of JBP_PORTLET_STATE using the PK value to identify it.

          The PK usually is then modified a bit by the portlet container, it is prefixed by an "_" in order to make the distinction between portlet IDs and customizations which points to a portlet ID.

          Then this PK is stored in the InstanceContainer thing we have. Usually it is assocated with a customization context.

          For a shared portlet instance, the shared customizations PKs are stored in the InstanceDefinition with the table :

          CREATE TABLE `JBP_INSTANCE` (
           `PK` bigint(20) NOT NULL auto_increment,
           `ID` varchar(255) NOT NULL,
           `PORTLET_REF` varchar(255) default NULL,
           `MODIFIABLE` bit(1) NOT NULL,
           `SER_STATE` longblob,
           PRIMARY KEY (`PK`),
           UNIQUE KEY `ID` (`ID`)
          )


          Then when a portlet is further customized for a shared instance, the PK is stored in the table :

          CREATE TABLE `JBP_INSTANCE_PER_USER` (
           `PK` bigint(20) NOT NULL auto_increment,
           `INSTANCE_PK` bigint(20) default NULL,
           `SER_STATE` longblob,
           `USER_ID` varchar(170) NOT NULL,
           `PORTLET_REF` varchar(170) NOT NULL,
           PRIMARY KEY (`PK`),
           UNIQUE KEY `USER_ID` (`USER_ID`,`PORTLET_REF`)
          )


          In that case, the customization key is the user ID

          For dashboard pages, the customization key is window ID (if I recall correctly) providing the capability to customize portlet several times in the same page.

          • 2. Re: javax.portlet.PortletPreferences;
            Christopher Logan Newbie

            Thank you very much!! Do you recommend using this as opposed to custom portlet solution for user customizations? I mean, if the portlet requirement calls for persisting user customizations, to use a another database for persisting this information.

            Thank you,

            Christopher