9 Replies Latest reply on Oct 20, 2005 11:11 AM by Bradley Smith

    portlet layout in portal

    Mircea Trifan Newbie

      What file(s) contain the arangements of portlets into the example portal that comes with the distribution?
      I'd like to replace the helloworld example portlet with a new portlet.

      Thanks + regards,
      Mircea

        • 1. Re: portlet layout in portal
          ray lukas Newbie

          Well I am not an expert by any stretch.. Just started looking at portal stuff yesterday?. Actually I am trying to do the same thing as you are.. that is ?Figure out how to deploy a portlet into the portal?.. I changed the data source to PostgreSql without any trouble but a good deploy mechanism is something I am still searching for.
          While at the moment the Eclipse Jboss IDE plug-in does not seem to (I could be wrong) support such a task and a good technique still eludes me I can share somethings that I found with you.

          The JBoss Portal 2.0 Final document does a nice job at covering all the files (xml files) that the portal uses. I would look there, if I where you. You can find it at the same place you downloaded the portal server..

          Also on the sun web page (http://developers.sun.com/prodtech/portalserver/reference/techart/university.html) there is a document called Introduction to JSR 168 - The Portlet Specification which is very good which supplies code examples of a simple Weather Portlet. The sun portal university page has enough resources to choke a horse.

          I found both these to be quit useful.
          And if you figure out a simple way to deploy all this stuff let me know.. I am going crazy here.

          ray

          • 2. Re: portlet layout in portal - WHAT FILES TO EDIT
            Bradley Smith Master

            1.) \WEB-INF\portlet.xml

            - this is where you use the JSR 168 spec. to declare and configure your portlets to the portal.
            - this file is 'cross-platform'
            - the spec, .xsd, etc. are here
            Example:

             <portlet>
             <portlet-name>MyPortlet</portlet-name>
             <portlet-class>com.mydomain.portlets.MyPortlet</portlet-class>
             <init-param>
             <description>my init-param description...</description>
             <name>myInitParamName</name>
             <value>myInitParamValue</value>
             </init-param>
             <supports>
             <mime-type>text/html</mime-type>
             <portlet-mode>VIEW</portlet-mode>
             <portlet-mode>EDIT</portlet-mode>
             <portlet-mode>HELP</portlet-mode>
             </supports>
             <resource-bundle>com.mydomain.portlets.MyPortlet</resource-bundle>
             <portlet-info>
             <title>My Portlet</title>
             <keywords>my portlet</keywords>
             </portlet-info>
             <portlet-preferences>
             <preference>
             <name>somePreference</name>
             <value>somePreferenceValue</value>
             </preference>
             </portlet-preferences>
             </portlet>
            


            (the rest of these files are documented in the JBossPortalReferenceGuide (online or PDF - comes with portal download).

            2.) \WEB-INF\jboss-portlet.xml (JBoss Portal-specific file)

            - this file is kind of redundant to portlet.xml, but it's required for now by JBoss Portal (The portal should be able to deduce this info from portlet.xml (Don't Repeat Yourself).
            - basically, your portlet-name(s) musy match the portlet-name(s) you declared in portlet.xml.
            - for security, you will need to read the manual - the snippet below should get you started.
            <portlet-app>
             <portlet>
             <portlet-name>MyPortlet</portlet-name>
             <security></security>
             </portlet>
            </portlet-app>
            


            3.) \WEB-INF\portlet-instances.xml (JBoss Portal-specific file)

            - this file is required by JBoss Portal - basically you are creating an alias name for your portlets.
            - ideally, the portal could automate this for you, however, JBoss Portal is free and early in its lifecycle, so we help out and 'name' our portlets for the portal using this file.
            <instances>
             <instance>
             <instance-name>MyPortletInstance</instance-name>
             <component-ref>MyPortlet</component-ref>
             </instance>
            </instances>
            


            4.) \WEB-INF\my-portal.xml (JBoss Portal-specific file)

            - *-portal.xml (any .xml file that ends in -portal)
            - associates an instance of your portlet with a particular portal page (in this case the page is test http://mydomain.com/portal/test/index.html)

            <portal>
             <portal-name>test</portal-name>
            
             <properties>
             <!-- Set the default window for request of the type /a/b/c -->
             <property>
             <name>org.jboss.portal.property.action</name>
             <value>MyPortletWindow</value>
             </property>
             <!-- Set the layout for the default portal -->
             <!-- see also portal-layouts.xml -->
             <property>
             <name>org.jboss.portal.property.layout</name>
             <value>simple-layout-two-column</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>divRenderer</value>
             </property>
             <!-- set the default strategy name (used by the strategy interceptor) -->
             <!-- see also portal-strategies.xml -->
             <property>
             <name>org.jboss.portal.property.strategy</name>
             <value>default</value>
             </property>
             </properties>
            
             <supported-modes>
             <mode>VIEW</mode>
             <mode>EDIT</mode>
             <mode>HELP</mode>
             </supported-modes>
            
             <supported-window-states>
             <window-state>NORMAL</window-state>
             <window-state>MINIMIZED</window-state>
             <window-state>MAXIMIZED</window-state>
             </supported-window-states>
            
             <pages>
            
             <default-page>default</default-page>
            
             <page>
             <page-name>default</page-name>
             <window>
             <window-name>MyPortletWindow</window-name>
             <instance-ref>test.MyPortlet.MyPortletInstance</instance-ref>
             <region>top.left</region>
             <height>0</height>
             </window>
             <window>
            
             <window>
             <!-- other porlet (window) -->
             </window>
            
             <window>
             <!-- other porlet (window) -->
             </window>
            
             </page>
            
             </pages>
            </portal>
            


            Ultimately you shoul review the JBossPortalReferenceGuide, review the files of the portal sar which also demonstrate usage of the above files and then try your hand at creating your own portlets and portal pages.

            If you want to replace the Hello Word portlet, you can simply edit the following page and add in your portlet:

            ${JBOSS_HOME}\server\default\deploy\jboss-portal.sar\portal-core.war\WEB-INF\default-portal.xml

            Hope this helps.


            • 3. Re: portlet layout in portal
              ray lukas Newbie

              When I try this file with the following changes, which are slight, JBoss throws an exception. A null pointer exception in the StrategyFactory object. Do you know why.... or how I could go about debugging this..

              Here is my helloworld-portal.xml file:

              <?xml version="1.0" encoding="UTF-8"?>
              <!-- http://localhost:8080/portal/test/index.html -->
              <portal>
               <portal-name>test</portal-name>
              
               <properties>
               <!-- Set the default window for request of the type /a/b/c -->
               <property>
               <name>org.jboss.portal.property.action</name>
               <value>MyPortletWindow</value>
               </property>
               <!-- Set the layout for the default portal -->
               <!-- see also portal-layouts.xml -->
               <property>
               <name>org.jboss.portal.property.layout</name>
               <value>simple-layout-two-column</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>divRenderer</value>
               </property>
               <!-- set the default strategy name (used by the strategy interceptor) -->
               <!-- see also portal-strategies.xml -->
               <property>
               <name>org.jboss.portal.property.strategy</name>
               <value>default</value>
               </property>
               </properties>
              
               <supported-modes>
               <mode>VIEW</mode>
               <mode>EDIT</mode>
               <mode>HELP</mode>
               </supported-modes>
              
               <supported-window-states>
               <window-state>NORMAL</window-state>
               <window-state>MINIMIZED</window-state>
               <window-state>MAXIMIZED</window-state>
               </supported-window-states>
              
               <pages>
              
               <default-page>default</default-page>
              
               <page>
               <page-name>default</page-name>
               <window>
               <window-name>MyPortletWindow</window-name>
               <instance-ref>helloworld.HelloWorldPortlet.HelloWorldPortletInstance</instance-ref>
               <region>top.left</region>
               <height>0</height>
               </window>
               </page>
              
               </pages>
              </portal>
              



              Here is the exception.

              14:10:05,795 INFO [STDOUT] WURFL has been initialized
              14:10:05,889 ERROR [CoreServlet] Exception caught in processing servlet
              java.lang.NullPointerException
               at org.jboss.portal.core.theme.strategy.StrategyFactory.createStrategyContext(StrategyFactory.java:55)
               at org.jboss.portal.core.invocation.StrategyInterceptor.invoke(StrategyInterceptor.java:141)
               at org.jboss.portal.server.impl.invocation.InvocationImpl.invokeNext(InvocationImpl.java:213)
               at org.jboss.portal.core.invocation.ViewInterceptor.invoke(ViewInterceptor.java:118)
               at org.jboss.portal.server.impl.invocation.InvocationImpl.invokeNext(InvocationImpl.java:213)
               at org.jboss.portal.server.invocation.portal.TargetInterceptor.invoke(TargetInterceptor.java:153)
               at org.jboss.portal.server.impl.invocation.InvocationImpl.invokeNext(InvocationImpl.java:213)
               at org.jboss.portal.core.invocation.ContentTypeInterceptor.invoke(ContentTypeInterceptor.java:117)
               at org.jboss.portal.server.impl.invocation.InvocationImpl.invokeNext(InvocationImpl.java:213)
               at org.jboss.portal.core.invocation.UserContextInterceptor.invoke(UserContextInterceptor.java:92)
               at org.jboss.portal.server.impl.invocation.InvocationImpl.invokeNext(InvocationImpl.java:213)
               at org.jboss.portal.server.impl.invocation.InvocationImpl.invokeNext(InvocationImpl.java:238)
               at org.jboss.portal.server.PortalServer.invoke(PortalServer.java:186)
               at org.jboss.portal.server.servlet.AbstractMainServlet.invoke(AbstractMainServlet.java:78)
               at org.jboss.portal.server.servlet.AbstractMainServlet.doGet(AbstractMainServlet.java:71)
               at javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
               at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
               at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
               at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
               at org.jboss.portal.core.servlet.TransactionFilter.doFilter(TransactionFilter.java:79)
               at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
               at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
               at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
               at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
               at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
               at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
               at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
               at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
               at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:153)
               at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:407)
               at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
               at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
               at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
               at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
               at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
               at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
               at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
               at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
               at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
               at java.lang.Thread.run(Thread.java:534)
              14:10:05,889 ERROR [[PortalServlet]] Servlet.service() for servlet PortalServlet threw exception
              java.lang.NullPointerException


              • 4. Re: portlet layout in portal
                Bradley Smith Master

                Try changing this:

                 <property>
                 <name>org.jboss.portal.property.layout</name>
                 <value>simple-layout-two-column</value>
                 </property>
                 ...
                 <property>
                 <name>org.jboss.portal.property.renderSet</name>
                 <value>divRenderer</value>
                 </property>
                


                to this:

                 <property>
                 <name>org.jboss.portal.property.layout</name>
                 <value>nodesk</value>
                 </property>
                 ...
                 <property>
                 <name>org.jboss.portal.property.renderSet</name>
                 <value>emptyRenderer</value>
                 </property>
                
                


                I have been using a custom theme in my work and I forgot to change these values back to the defaults for the JBoss Portal.

                Good luck

                • 5. Re: portlet layout in portal
                  ray lukas Newbie

                  Thanks Brad.
                  Hey you are in Boston.. I am probably right down the street from you.
                  Not sure what I changed but I am not longer having this crash any more.
                  Brad I need a hand with some JBoss Portal things.
                  Do you know how to deploy a portlet, which runs in its own Portal. I have to build a portal for my company and I can?t use the default JBoss Portlet page.
                  Do you know how to create your own Portal definition and put the hello world portlet into it. I think that I am doing everything right but it does not work. It keeps coming up in the JBoss Portal window.
                  I want to make a ?company? portal window and have hello world come up in that. That is the whole point of this helloworld-portal.xml file. How do you do this..
                  ray

                  • 6. Re: portlet layout in portal
                    ray lukas Newbie

                    Brad, is the only way to modify what the portal looks like to modify the portal-core.war/WEB-INF/default-portal.xml file..
                    Can I have my own helloworld-portal.xml file living inside a helloworld.war/WEB-INF directory and simply modify that one. Your last posting triggered a good insight for me. For instance, couldn't I just take the themes and layouts from download.jboss.com/jbossportal/themes/myLayout.war.zip (could have type that wrong) and place them into my own war file, and if so HOW, or must I always use the portal-core branch.
                    Do you see what I am asking?

                    • 7. Re: portlet layout in portal
                      Bradley Smith Master

                      Yes - if you want to modify what the portal looks like, you must modify

                      portal-core.war/WEB-INF/default-portal.xml

                      The way I deal with custom portal pages is to create my own layout/theme(s).

                      Then, I set the default-portal to use my desired layout/theme and I develop arbitrary portal pages based on my layout/theme.

                      In default/deploy you might have several things deployed, like this:

                      ${JBOSS_HOME}/server/default/deploy/
                       ...
                       jboss-portal.sar
                       ...
                       three-column-theme.war
                       two-column-theme.war
                       fancy-theme.war
                       blue-theme.war
                       green-theme.war
                       ...
                       news-portal.war
                       reports-portal.war
                       ...
                       portal-ds.xml
                       ...
                      


                      Each *-theme.war is a custom layout/theme
                      Each *-portal.war is a specific portal page (or set of portal pages)
                      portal-ds.xml contiains each of the datasources your portal(s) use.

                      NOTE - the reference guide explains how you create URL's for your portal pages.

                      Hope this helps.

                      Brad


                      • 8. Re: portlet layout in portal
                        ray lukas Newbie

                        GOT IT.. Yeah, my thinking has been confirmed.. Crystal man.. Crystal clear.. That is what I thought.. See your last post triggered that in my brain.. I did read Roy's chapter, actually I glossed over it (sorry Roy) and after reading your last post I saw the error of my ways and went back and really read it, it is a good chapter.. Thanks Roy, wherever you are.. But this confirms what I was thinking. hey man.. Thanks a lot for helping me out.. Confirmation, from someone that knows.. I think that I am starting to get the hang of this thing.. It is not to bad, just have to get a couple ideas straight first and play with it a while.. It is really pretty straight forward once you get the model in you brain drawn up correctly.. It all makes sense..
                        Right now I have two portlets Car Demo and Helloworld on the same page and I now have a pretty good idea of how to make that page look like our company page and not the JBoss Portal Server page, beautiful as it is.....
                        So that makes me feel pretty happy. I will still work most of the night but hey today is a good day and it is not over yet. I am feeling pretty good right now..

                        Look I work in Cambridge.. If you ever want to do a lunch or something it is on me.. Just offering..

                        Thanks man,
                        ray

                        • 9. Re: portlet layout in portal
                          Bradley Smith Master

                          Lunch - lol -ok someday maybe ;-)