3 Replies Latest reply on Apr 6, 2006 4:31 PM by hr_k

    CMS Portlet and indexpage problem

    keletappi

      I have tried to figure out how to create CMS Portlet that actually shows
      different startpage from default one.

      I noticed that somebody has implemented indexpage as init-param while it should be implemented as preferences instead.

      Init parameters are common to all instances of same portlet. So If you want to create instance with other starting page, you need to create another portlet from same class.

      However if you implement starting page with preferences, one portlet is enough because preferences are per instance.

      Here is what is currently in portlet definition:

       <portlet>
       <portlet-name>CMSPortlet</portlet-name>
       <portlet-class>org.jboss.portal.core.portlet.cms.CMSPortlet</portlet-class>
       <init-param>
       <description>Default path to index page.</description>
       <name>indexpage</name>
       <value>/default/index.html</value>
       </init-param>
       <supports>
       <mime-type>text/html</mime-type>
       <portlet-mode>VIEW</portlet-mode>
       </supports>
       <supported-locale>en</supported-locale>
       <supported-locale>fr</supported-locale>
       <supported-locale>es</supported-locale>
       <resource-bundle>Resource</resource-bundle>
       <portlet-info>
       <title>CMS</title>
       </portlet-info>
       </portlet>
      


      And it should be something like this:

       <portlet>
       <portlet-name>CMSPortlet</portlet-name>
       <portlet-class>org.jboss.portal.core.portlet.cms.CMSPortlet</portlet-class>
       <supports>
       <mime-type>text/html</mime-type>
       <portlet-mode>VIEW</portlet-mode>
       </supports>
       <supported-locale>en</supported-locale>
       <supported-locale>fr</supported-locale>
       <supported-locale>es</supported-locale>
       <resource-bundle>Resource</resource-bundle>
       <portlet-info>
       <title>CMS</title>
       </portlet-info>
       <portlet-preferences>
       <preference>
       <name>indexpage</name>
       <value>/default/index.html</value>
       </preference>
       </portlet-preferences>
       </portlet>
      
      



        • 1. Re: CMS Portlet and indexpage problem
          keletappi

          I clarify a bit.

          When using preferences it would be possible to set indexpage in *-object.xml deployments without defining new portlet.

           <deployment>
           <if-exists>overwrite</if-exists>
           <instance>
           <instance-name>CMS_SupportPage</instance-name>
           <component-ref>portal.CMSPortlet</component-ref>
          
           <preferences>
           <preference>
           <name>indexpage</name>
           <value>/default/support.html</value>
           <read-only>false</read-only>
           </preference>
           </preferences>
          
          
           </instance>
           </deployment>
          
          


          • 2. Re: CMS Portlet and indexpage problem

            This feature was added to 2.4. Thanks.

            • 3. Re: CMS Portlet and indexpage problem
              hr_k

              Thanks for you advice - I had the same problem.

              To make it work with perferences on portal v2.2, one need to add the flowing code to CMSPortlet.java.

              Insert this in the beging of doView:

              String tmpIndexpage = req.getPreferences().getValue("indexpage", LINK_MODE_PORTLET);
               if(!LINK_MODE_PORTLET.equals(tmpIndexpage)) {
               log.info("sets the new cms page to "+tmpIndexpage );
               indexpage=tmpIndexpage;
               }


              This why you change the value of the indexPage (which is set at init), to the on from the portlet perference.

              Of course a rebuild of the source is needed.