7 Replies Latest reply on Sep 3, 2007 2:14 AM by habicht

    preferences in portlet-instances.xml

    habicht

      hi! i'm trying to read preferences out of the portlet-instances.xml but it doesn't work. i've read other posts concerning the same topic but i couldn't find a solution. the only thing that works is getting the value from the portlet.xml file.

      public class PortletA extends GenericPortlet
      {
      protected void doView(RenderRequest request, RenderResponse response)
      throws PortletException, PortletSecurityException, IOException
      {
      System.out.println(request.getPreferences().getValue
      }

      }


      <?xml version="1.0" encoding="UTF-8"?>
      <portlet-app id="PortletA" version="1.0">
      <portlet id="PortletA">
      <portlet-name>portleta</portlet-name>
      <display-name>portleta</display-name>
      <portlet-class>test.PortletA</portlet-class>
      <expiration-cache>0</expiration-cache>
      <supports>
      <mime-type>text/html</mime-type>
      <portlet-mode>VIEW</portlet-mode>
      </supports>
      <portlet-info>
      <short-title>Portlet A</short-title>
      <keywords>Portlet</keywords>
      </portlet-info>
      <portlet-preferences>
      <preference>
      <name>test</name>
      <value>portlet.xml</value>
      </preference>
      </portlet-preferences>
      </portlet>
      </portlet-app>


      <deployments>
      <deployment>
      <instance>
      <instance-id>PortletAInstance</instance-id>
      <portlet-ref>portleta</portlet-ref>
      <preferences>
      <preference>
      <name>test</name>
      <value>portlet-instances.xml</value>
      </preference>
      </preferences>
      </instance>
      </deployment>
      </deployments>


      so looking at my files this means that i receive portlet.xml inestad of portlet-instances.xml

      Windows XP Pro SP2
      jdk 1.5.0_09
      JBoss Portal 2.6 Bundle (binary)
      Postgres 8.3
      Hibernate 3

      thanks in advance
      habicht

        • 1. Re: preferences in portlet-instances.xml
          habicht

          ups! used quote instead of code.

          • 2. Re: preferences in portlet-instances.xml
            peterj

            Your syntax looks correct. Use the Management Portlet to double-check the portlet instances defined to the portal and make sure that your instance has the preferences set.

            • 3. Re: preferences in portlet-instances.xml
              habicht

              thanks for your answer. i found out that i had to wipe the database in order to refresh the value of the preferences in the instances. redeploying and rebooting the jboss doesn't work but if the database is rebuilt the preferences are set with the correct value.

              • 4. Re: preferences in portlet-instances.xml
                theute

                While reading this i had a close look at it and found a bug that doesn't seem related to what you are trying.

                New values of the preferences should be picked (in portlet-instances.xml)

                The bug was if you removed a portlet preference from portlet-instances, the data wasn't actually removed.

                I'm still curious to know why it fails for you, if you just added or updated a value it should work (i tried again with the weather portlet)

                • 5. Re: preferences in portlet-instances.xml
                  peterj

                  Personally, I have found that making changes in the configuration files is not a guarantee that those changes will be reflected in the portal on restart. Therefore I always start with a clean install when I make such changes. Of course I have the luxury of being able to do so because usually I am experimenting with non-production portals. In a production portal, I rely on the Management Portlet to make any such changes. Works every time. And when you think about it, using the configuration files to perform an initial load of your portlet and then using the Management Portlet to tweak and modify the configuration is a very logical way of approaching portal management.

                  • 6. Re: preferences in portlet-instances.xml
                    kpalania

                    I agree. I am having to do a clean install as well, and this wasn't very intuitive :(

                    I've made it a practice now and is part of the ANT target!

                    • 7. Re: preferences in portlet-instances.xml
                      habicht

                      i tried again with other portlets. after adding the necessary info into the portlet.xml and portlet-instances.xml, deploying and restarting, i only received the value from the portlet.xml file. after wiping the database again i got the correct value from the portlet-instances.xml file.