3 Replies Latest reply on Apr 12, 2006 5:29 PM by Scott Dawson

    Deployment of same portlet with different config

    Scott Dawson Apprentice

      I have a general question about deploying portlets and I don't see this scenario covered in the portlet spec. I want to deploy multiple instances of the same portlet, but with different configuration parameters in portlet.xml. For example, I might want two RSS portlets which are the same except for different configuration (different feed URLs) in portlet.xml. The ugly way to do it is to deploy two warfiles which differ only in portlet.xml. But what I'd like to do is only deploy the war once and provide XML files for the different instances. Does anyone know a clean way to do this? Is there a non-proprietary, spec-compliant way? Is this something that might be addressed in the 2.0 portlet spec?

      Thanks,
      Scott

        • 1. Re: Deployment of same portlet with different config
          Rab Boyce Newbie

          did you ever manage to solve this problem?

          • 2. Re: Deployment of same portlet with different config
            Scott Dawson Apprentice

            Yes, I was overlooking the obvious. Probably the best way to deploy two (or more) instances of a portlet is with multiple portlet elements in portlet.xml, so you end up with something like this:

            <portlet-app ...>
             <portlet>
             <portlet-name>MyPortlet</portlet-name>
             <portlet-class>com.unisys.portlets.ThePortlet</portlet-class>
             <!-- portlet configuration goes here,
             like title, init-params, preferences, etc. -->
             </portlet>
             <portlet>
             <portlet-name>YourPortlet</portlet-name>
             <portlet-class>com.unisys.portlets.ThePortlet</portlet-class>
             <!-- portlet configuration goes here,
             like title, init-params, preferences, etc. -->
             </portlet>
            </portlet-app>
            

            There are at least 2 advantages to solving the problem this way:
            1) You can change almost anything configurable: the title, init-params, preferences; anything in portlet.xml
            2) It's JSR-168 compliant and so it should be portable

            Alternatively, there are a couple of JBoss Portal-specific ways you can solve the problem but they only allow you to override Preferences and not other attributes like the portlet title. The first Portal-specific way is to override preferences in the *-object.xml file, documented here:http://docs.jboss.com/jbportal/v2.2/reference-guide/en/html/xmldescriptors.html#d0e860
            The other way is to use the JBoss Portal management portlet to create multiple instances of a portlet and then override preferences, documented here:
            http://docs.jboss.com/jbportal/v2.2/user-guide/en/html/dynamicity.html#d0e1177

            Regards,
            Scott Dawson
            Unisys


            • 3. Re: Deployment of same portlet with different config
              Scott Dawson Apprentice

              The JBoss Portal Reference Guide shows how to override preferences in the *-object.xml file (section 3.5). I can't get it to work. Has anyone been successful with this? Here is the example XML from the reference guide:

              <deployment>
               <if-exists>overwrite</if-exists>
               <instance>
               <instance-name>HelloWorldPortletInstance</instance-name>
               <component-ref>helloworld.HelloWorldPortlet</component-ref>
               <preferences>
               <preference>
               <name>foo</name>
               <value>bar</value>
               <read-only>false</read-only>
               </preference>
               </preferences>
               </instance>
              </deployment>
              


              I don't get any errors but the specified override values do not take effect. I've tried dropping the database, deleting the temp directories, etc.

              Thanks,
              Scott