3 Replies Latest reply on Jan 4, 2006 11:07 AM by mholzner

    change layout only in my portlet

    pedrosacosta

      JBoss AS: 4.0.2
      JBoss Portal: 2.0

      Hi,

      I have built a layout (mylayout.war) and a portlet (myportlet.war) that works. But now, i want configure my xml files to set the layout only to my portlet.

      I've already saw the change layout example in forums. But, i want only change the layout in my portlet, and not in all the portal.

      Is it possible? If so, how?

      Thanks,
      Pedro

        • 1. Re: change layout only in my portlet

          not sure, but I think your definition of layout is probably different from mine, so I don't know if what I can tell you makes sense to you.....

          Let's try anyway:
          The layout is the jsp that renders the returned markup (the entire page). So it is the part that creates the HTML, TITLE, BODY , etc. tags

          A portlet is only a part of that rendered markup. So when you talk about the layout in a portlet, I'm not sure what you mean. My guess is that you are talking about the theme: the look and feel of the markup that is rendered by the portlet. If that assumption is correct, then I'd recommend to use the WSRP CSS selectors in your portlets markup , and a css file that uses these ids and classes to style / theme the page fragment.

          • 2. Re: change layout only in my portlet
            pedrosacosta

            What i'm saying is, by default, the structure of the pages in the portal is: ___________
            | | |
            |left | center |
            |___|_______|

            That's what i understand according to the tag region displayed in the default-portal.xml.

             <page>
             <page-name>cache test</page-name>
             <window>
             <window-name>CachedCounterPortletWindow</window-name>
             <instance-ref>CachedCounterPortletInstance</instance-ref>
             <region>center</region>
             <height>0</height>
             </window>
             <window>
             <window-name>CounterPortletWindow</window-name>
             <instance-ref>CounterPortletInstance</instance-ref>
             <region>center</region>
             <height>1</height>
             </window>
             </page>
             <page>
             <page-name>session test</page-name>
             <window>
             <window-name>PortletSessionPortletWindow</window-name>
             <instance-ref>PortletSessionPortletInstance</instance-ref>
             <region>center</region>
             <height>0</height>
             </window>
             </page>
             <page>
             <page-name>missing portlet</page-name>
             <window>
             <window-name>MissingPortletWindow</window-name>
             <instance-ref>MissingPortletInstance</instance-ref>
             <region>center</region>
             <height>0</height>
             </window>
             </page>
             <page>
             <page-name>missing instance</page-name>
             <window>
             <window-name>MissingInstanceWindow</window-name>
             <instance-ref>MissingInstance</instance-ref>
             <region>center</region>
             <height>0</height>
             </window>
             </page>
             <page>
             <page-name>charset test</page-name>
             <window>
             <window-name>CatalogPortletWindow</window-name>
             <instance-ref>CatalogPortletInstance</instance-ref>
             <region>left</region>
             <height>0</height>
             </window>
             <window>
             <window-name>CharsetPortletWindow</window-name>
             <instance-ref>CharsetPortletInstance</instance-ref>
             <region>center</region>
             <height>0</height>
             </window>
             </page>
             <page>
            


            The region says in which region of the jsp the portlet should shown.

            But for my portlet, i want a layout like this:
            _________________
            |_____Top________|
            | | | |
            |left | center | right |
            |___|_______|_____|
            |____Bottom______ |


            I can change the layout of the portal, modifying the default-portal.xml file:

            <property>
             <name>org.jboss.portal.property.layout</name>
             <value>nodesk</value>
             </property>
             <!-- set the default render set name (used by the render tag in layouts) -->
             <!-- see also portal-renderSet.xml -->
             <property>
             <name>org.jboss.portal.property.renderSet</name>
             <value>emptyRenderer</value>
             </property>
            


            and creating my jsp:

            <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
            <%@ taglib uri="/WEB-INF/theme/portal-layout.tld" prefix="p" %>
            <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"><head>
             <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"/>
            
             <!-- insert the dynamically determined theme elements here, or use the 'simple-sample' theme by default -->
             <p:theme themeName='simple-sample' />
            
            <body>
            
            <!-- header table -->
            <table class="headerTable">
            <tr>
            <td align="center">
            <img src="/myLayout/images/carris_logo.gif" />
            </td>
            </tr>
            </table>
            <table>
            <tr>
            <!-- Menus criados pelo portal -->
            <td class="topRow"><p:region regionName='top'/></td>
            <td><p:region regionName='left'/></td>
            </tr>
            </table>
            
            <!-- center table with columns -->
            <table width="100%" bgcolor="#FFFFFF">
            <tr>
            <td class="centerColumn"><p:region regionName='center'/></td>
            <td class="rightColumn"><p:region regionName='right'/></td>
            </tr>
            </table>
            
            <!-- footer table -->
            <table class="footerTable">
            <tr>
            <td align="center"><p:region regionName='bottom'/></td>
            </tr>
            </table>
            
            </body>
            </html>
            


            But changing default-portal.xml, affects all the portal.

            I want to know how should i define a layout only for my portlet, and not for all the portal?

            I hope that i've explained well my problem.

            Thanks,
            Pedro

            • 3. Re: change layout only in my portlet

              please be careful with the term you are using. I'm still confused by your use of 'portlet', but anyway: I hope I got it now.

              You can have a layout for the entire portal, but you can overwrite it for individual pages via page properties. You can define a jsp that does your layout with top, left,center,right,bottom, and assign it only to the page(s) that you want it for. All other pages in the portal will still get the layout that was defined for the portal (with the center, left, and navigation regions)

              Here is an example for such a page level layout:

              <deployments>
               <deployment>
               <parent-ref/>
               <if-exists>keep</if-exists>
               <portal>
               <portal-name>default</portal-name>
               <properties>
               <property>
               <name>layout.id</name>
               <value>generic</value>
               </property>
               ........
               </properties>
               <page>
               <page-name>myPage</page-name>
               <properties>
               <property>
               <name>layout.id</name>
               <value>myspecialLayout</value>
               </property>
               ........
               </properties>
              
               .....
               </portal>
               ....
              </deployments>
              


              'myPage' will get rendered with 'myspecialLayout', all other pages in the 'default' portal will be rendered with the 'generic' layout.

              Please use the 'generic' layout as your starting point for a customized layout. The 'nodesk' layout is still in the 2.0 way (left there for compatibility reasons) of layouts and themes, and a lot harder to maintain, and less flexible.