1 2 Previous Next 20 Replies Latest reply on Aug 25, 2005 11:40 AM by Alan Strait

    Instatiating portlet from another portal

    Marcel Kostal Newbie

      Is there a way how can I instantiate portlets from another portal?

      I have created new WAR file containing portlet-instances.xml as well as refproj-portal.xml. I wanted to instatiate ContentPortlet (defined in default portal - portal-core.war) with different URI property, therefore I wrote this into portlet-instances.xml:

      <instance>
       <instance-name>MyContentPortletInstance</instance-name>
       <component-ref>ContentPortlet</component-ref>
       <preferences>
       <preference>
       <name>uri</name>
       <value>/refproj/page2/index.html</value>
       </preference>
       </preferences>
       </instance>


      Than I used this "MyContentPortletInstance" in my portal page, but when I browsed the page, the Portlet was not rendered. I found that the ViewInterceptor doesn't put window containing this Portlet into list of windows to render, because it's state is REGISTERED (and not STARTED).

        • 1. Re: Instatiating portlet from another portal
          Patrick Dalla Bernardina Apprentice

          I have the same problem.

          Had you solved?

          • 2. Re: Instatiating portlet from another portal
            Marcel Kostal Newbie

             

            "patrickdalla" wrote:
            I have the same problem.

            Had you solved?


            No. Or partially. I'm not using standart Portlets like ContentPortlet... and I'm deploying portals, portletInstances, portlets by myself within my only WAR file in the servlet that starts on load.

            • 3. Re: Instatiating portlet from another portal
              Dave Muirhead Newbie

               

              "marec" wrote:
              Is there a way how can I instantiate portlets from another portal?


              I'd really like to hear a clear answer to this question, as well.

              The broader question, which has also been asked but also not been clearly answered as far as I can tell, is what is the procedure to create a custom portal (as opposed to editing the default portal that is shipped in portal-core.war) that consumes any combination of custom and JBoss-provided portlets (e.g., ContentPortlet)?

              Maybe a concrete test case would help the discussion...

              For example, I can't find any documentation or forum posts that indicates that it shouldn't be possible to create a custom portal (on JBoss Portal 2.0) composed of:

              a) the "2ColumnLayout", provided as myLayout.war on the JBoss Portal wiki
              b) the HelloWorld portlet, provided as helloworld.war on the JBoss Portal wiki
              c) the Content portlet, provided in portal-core.war within the JBoss Portal SAR

              Assuming JBoss Portal is installed as described in the User Guide, I would have thought the steps would be the following (I've included JBoss server console output for each step):

              1) deploy helloworld.war by copying to $JBOSS_HOME/server/default/deploy

              13:52:21,890 INFO [TomcatDeployer] deploy, ctxPath=/helloworld, warUrl=file:/opt/jboss-4.0.2/server/default/deploy/helloworld.war/
              13:52:22,270 INFO [PortalServer] Added application /helloworld
              


              2) deploy myLayout.war by copying to $JBOSS_HOME/server/default/deploy

              13:53:08,469 INFO [TomcatDeployer] deploy, ctxPath=/myLayout, warUrl=file:/opt/jboss-4.0.2/server/default/deploy/myLayout.war/
              13:53:08,683 INFO [ContextConfig] Missing application web.xml, using defaults only StandardEngine[jboss.web].StandardHost[localhost].StandardContext[/myLayout]
              13:53:08,849 INFO [LayoutDeployment] new layout deployer for : /myLayout
              13:53:08,850 INFO [ThemeDeployment] new theme deployer for : /myLayout
              13:53:08,860 INFO [LayoutDeployment] create new layout(s), found in : /myLayout
              13:53:08,878 INFO [LayoutDeployment] done creating new layout(s), found in : /myLayout
              13:53:08,880 INFO [ThemeDeployment] create new theme(s), found in : /myLayout
              13:53:08,890 INFO [ThemeDeployment] done creating new theme(s), found in : /myLayout
              


              3) deploy custom.war (containing the files shown below) by copying to $JBOSS_HOME/server/default/deploy

              13:53:39,142 INFO [TomcatDeployer] deploy, ctxPath=/custom, warUrl=file:/opt/jboss-4.0.2/server/default/tmp/deploy/tmp7971custom.war/
              13:53:39,456 INFO [PortalServer] Added portal custom
              13:54:04,121 WARN [TagLibCache] Internal Error: File /WEB-INF/web.xml not found
              


              The contents of custom.war:

              custom.war/WEB-INF/portlet-instances.xml:
              
              <?xml version="1.0" standalone="yes"?>
              <instances>
               <instance>
               <instance-name>CustomHelloWorldPortletInstance</instance-name>
               <component-ref>HelloWorldPortlet</component-ref>
               </instance>
               <instance>
               <instance-name>CustomContentPortletInstance</instance-name>
               <component-ref>ContentPortlet</component-ref>
               </instance>
              </instances>
              
              custom.war/WEB-INF/custom-portal.xml:
              
              <?xml version="1.0" encoding="UTF-8"?>
              <portal>
               <portal-name>custom</portal-name>
               <properties>
               <property>
               <name>org.jboss.portal.property.layout</name>
               <value>2ColumnLayout</value>
               </property>
               </properties>
               <!-- ...etc... -->
               <pages>
               <default-page>home</default-page>
               <page>
               <page-name>home</page-name>
               <window>
               <window-name>CustomHelloWorldPortletWindow</window-name>
               <instance-ref>custom.HelloWorldPortlet.CustomHelloWorldPortletInstance</instance-ref>
               <region>left</region>
               <height>0</height>
               </window>
               <window>
               <window-name>CustomContentPortletWindow</window-name>
               <instance-ref>custom.ContentPortlet.CustomContentPortletInstance</instance-ref>
               <region>center</region>
               <height>0</height>
               </window>
               </page>
               </pages>
              </portal>
              
              custom.war/WEB-INF/jboss-app.xml:
              
              <jboss-app>
               <app-name>custom</app-name>
              </jboss-app>
              
              custom.war/WEB-INF/jboss-web.xml:
              
              <?xml version="1.0"?>
              <jboss-web>
               <context-root>/custom</context-root>
              </jboss-web>
              
              custom.war/WEB-INF/web.xml:
              
              <?xml version="1.0"?>
              <!DOCTYPE web-app PUBLIC
               "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
               "http://java.sun.com/dtd/web-app_2_3.dtd">
              <web-app>
              </web-app>
              


              When I pointed my browser at http://localhost:8080/portal/custom/, I see a JBoss Portal using the MyLayout (as expected) but with no portlets (not as expected). The server console outputs:

              13:54:04,905 WARN [RegionTagHandler] requested page has no region [left]
              13:54:04,905 WARN [RegionTagHandler] requested page has no region [center]
              


              Obviously something is not right. I suppose marec's note about the portlet not being STARTED state might explain this, but noone from JBoss ever commented on that so who knows.

              I thought maybe I should include a portlet.xml that (re-)defines the HelloWorld and ContentPortlet portlets (and I made the corresponding changes to the component-ref elements of the porlet-instances.xml file):

              custom.war/WEB-INF/portlet.xml:
              
              <?xml version="1.0" encoding="UTF-8"?>
              <portlet-app
               xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd"
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
               xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd /opt/SUNWps/dtd/portlet.xsd" version="1.0">
               <portlet>
               <portlet-name>CustomHelloWorldPortlet</portlet-name>
               <portlet-class>org.jboss.portlet.helloworld.HelloWorld</portlet-class>
               <supported-locale>en</supported-locale>
               <supports>
               <mime-type>text/html</mime-type>
               <portlet-mode>VIEW</portlet-mode>
               </supports>
               <portlet-info>
               <title>Custom HelloWorld Portlet</title>
               </portlet-info>
               </portlet>
               <portlet>
               <portlet-name>CustomContentPortlet</portlet-name>
               <portlet-class>org.jboss.portal.core.portlet.cms.ContentPortlet</portlet-class>
               <supported-locale>en</supported-locale>
               <supports>
               <mime-type>text/html</mime-type>
               <portlet-mode>VIEW</portlet-mode>
               </supports>
               <portlet-info>
               <title>Content</title>
               </portlet-info>
               <portlet-preferences>
               <preference>
               <name>uri</name>
               <value>/default/index.html</value>
               </preference>
               </portlet-preferences>
               </portlet>
              </portlet-app>
              


              but then I get the following when I try to deploy custom.war:

              15:39:19,754 INFO [TomcatDeployer] deploy, ctxPath=/custom, warUrl=file:/opt/jboss-4.0.2/server/default/tmp/deploy/tmp7973custom.war/
              15:39:19,999 INFO [PortalServer] Added portal custom
              15:39:20,079 INFO [PortalServer] Added application /custom
              15:39:20,087 ERROR [PortletAppDeployment] The portlet cannot be started due to an error that occcured during init
              org.jboss.portal.portlet.PortletInitializationException: Portlet class not found org.jboss.portlet.helloworld.HelloWorld
               at org.jboss.portal.portlet.PortletContainer.start(PortletContainer.java:147)
               at org.jboss.portal.server.kernel.StartMethod.invokeMethod(StartMethod.java:37)
               ...etc...
              Caused by: java.lang.ClassNotFoundException: org.jboss.portlet.helloworld.HelloWorld
               at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1332)
               at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1181)
               at org.jboss.portal.portlet.PortletContainer.start(PortletContainer.java:125)
               ... 82 more
              


              If someone can help me figure this out, I'd be happy to contribute an example custom portal war with some doc about how to build and deploy it.

              Thanks in advance.

              -Dave


              • 4. Re: Instatiating portlet from another portal
                Roy Russo Master

                Perhaps the docs are not explicit enough. Here is a portal named "echo" that has contentPortlet and HelloWorldPortlet on the default page.

                echo-portal.xml

                <?xml version="1.0" encoding="UTF-8"?>
                <portal>
                 <portal-name>echo</portal-name>
                 <properties>
                 <!-- Set the default window for request of the type /a/b/c -->
                 <property>
                 <name>org.jboss.portal.property.action</name>
                 <value>CMSPortletWindow</value>
                 </property>
                 <!-- Set the layout for the default portal -->
                 <!-- see also portal-layouts.xml -->
                 <property>
                 <name>org.jboss.portal.property.layout</name>
                 <value>CarStoreLayout</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>CMSPortletWindow</window-name>
                 <instance-ref>portal.CMSPortlet.CMSPortletInstance</instance-ref>
                 <region>center</region>
                 <height>0</height>
                 </window>
                 <window>
                 <window-name>UserPortletWindow1</window-name>
                 <instance-ref>portal.UserPortlet.UserPortletInstance</instance-ref>
                 <region>left</region>
                 <height>0</height>
                 </window>
                 <window>
                 <window-name>CatalogPortletWindow1</window-name>
                 <instance-ref>portal.CatalogPortlet.CatalogPortletInstance</instance-ref>
                 <region>left</region>
                 <height>1</height>
                 </window>
                 <window>
                 <window-name>ContentPortletWindow1</window-name>
                 <instance-ref>portal.ContentPortlet.ContentPortletInstance</instance-ref>
                 <region>left</region>
                 <height>2</height>
                 </window>
                 <window>
                 <window-name>HelloWorldPortletWindow</window-name>
                 <instance-ref>helloworld.HelloWorldPortlet.HelloWorldPortletInstance</instance-ref>
                 <default>true</default>
                 <region>left</region>
                 <height>3</height>
                 </window>
                 </page>
                 <page>
                 <page-name>admin</page-name>
                 <window>
                 <window-name>AdminCMSPortletWindow</window-name>
                 <instance-ref>portal.AdminCMSPortlet.AdminCMSPortletInstance</instance-ref>
                 <region>center</region>
                 <height>2</height>
                 </window>
                 <window>
                 <window-name>UserPortletWindow2</window-name>
                 <instance-ref>portal.UserPortlet.UserPortletInstance</instance-ref>
                 <region>left</region>
                 <height>0</height>
                 </window>
                 <window>
                 <window-name>RolePortletWindow</window-name>
                 <instance-ref>portal.RolePortlet.RolePortletInstance</instance-ref>
                 <region>left</region>
                 <height>1</height>
                 </window>
                 <window>
                 <window-name>PermissionPortletWindow</window-name>
                 <instance-ref>portal.PermissionPortlet.PermissionPortletInstance</instance-ref>
                 <region>left</region>
                 <height>1</height>
                 </window>
                 </page>
                 </pages>
                </portal>
                


                • 5. Re: Instatiating portlet from another portal
                  Marcel Kostal Newbie

                  Will this work? Or this of course will work, but it isn't what we wanted.
                  The "echo" portal is using portlet instances defined in another portal, isn't it?. What we want is to define new instance within this "echo" portal and use it, not the one defined elsewhere. Because we want to specify different properties for the portlet instance than those defined in another portal.

                  • 6. Re: Instatiating portlet from another portal
                    Roy Russo Master

                    ok, so the echo portal above has an instance of HelloWorldPortlet in it. I removed the helloworld-pages.xml from the helloworld.war, so now it only exists in this echo portal.

                    • 7. Re: Instatiating portlet from another portal
                      Dave Muirhead Newbie

                      Roy-

                      Thanks for jumping in on this. I have a few more questions for you on this.

                      "roy.russo@jboss.com" wrote:
                      ok, so the echo portal above has an instance of HelloWorldPortlet in it.


                      1) I'd really appreciate if you would actually show how you accomplished this. I assume you have a portlet-instances.xml file for echo portal? If so, please post it. In fact, please post all of the config files for echo portal, or (even better) make a .war file available on the wiki.

                      2) Also, can you clarify the rules regarding instance-ref values (as occur in *-portlet.xml and *-pages.xml files)? I ask because your echo-portal.xml has instance-ref's referring to "portal" and "helloworld" applications and I wonder how those application names relate to the definiton/use of portlet instances (particularly once you removed the helloworld-pages.xml file from helloworld.war).

                      instance-ref's seem to be composed of 3 tokens, as described in the reference manual:

                      ...first you have the application name as defined in jboss-portlet.xml, the name of the portlet (as defined in portlet.xml) another dot and finally the name of the portlet instance (as defined in portlet-instances.xml...


                      a) with respect to the first token (the application name) - which application name?
                      - the application using the instance?
                      - the application defining the instance (via a portlet-instances.xml)?
                      - the application defining the portlet (via portlet.xml) whose instance is being used?

                      b) with respect to the second token (the portlet name) - in which application must the portlet be defined via portlet.xml? I was assuming only in the application in which the portlet (class and related resources) is deployed.

                      c) with respect to the third token (the portlet instance name) - which portlet-instances.xml file does this refer to?
                      - the one in the application using the instance?
                      - the one in the application named in the first token of the instance-ref value?

                      Thanks very much for clarifying.

                      -Dave


                      • 8. Re: Instatiating portlet from another portal
                        Roy Russo Master

                        ok... i will dissect these and post it in the wiki. stay tuned.

                        • 9. Re: Instatiating portlet from another portal
                          Roy Russo Master

                          As a side note, the helloworld.war and echo-portal.xml can be found here: http://download.jboss.com/jbossportal/random/deploy.zip

                          Remember: You will have to change the theme call in the echo-portal.xml for whatever theme you are using.

                          • 10. Re: Instatiating portlet from another portal
                            Roy Russo Master

                            Theres a ppt and a gif attached here: http://wiki.jboss.org/wiki/Wiki.jsp?page=JBossPortalXML

                            GIF is kind of big, so the ppt may be better to view.

                            • 11. Re: Instatiating portlet from another portal
                              Dave Muirhead Newbie

                               

                              "roy.russo@jboss.com" wrote:
                              ok... i will dissect these and post it in the wiki. stay tuned.



                              I'm not sure if you planning to answer my questions directly or if the PPT file on the wiki is your complete answer, but just in case the PPT file was your answer, I'll just go ahead and ask you to directly answer the questions from my previous posting in the form of words. I appreciate the picture in the PPT, but it doesn't answer the questions. Thanks.

                              -Dave


                              • 12. Re: Instatiating portlet from another portal
                                Roy Russo Master

                                A picture is worth a thousand words.

                                • 13. Re: Instatiating portlet from another portal
                                  Dave Muirhead Newbie

                                   

                                  "roy.russo@jboss.com" wrote:
                                  A picture is worth a thousand words.


                                  or a thousand questions

                                  • 14. Re: Instatiating portlet from another portal
                                    Dave Muirhead Newbie

                                     

                                    "roy.russo@jboss.com" wrote:
                                    A picture is worth a thousand words.


                                    Roy, frankly that sort of answer makes it hard for folks like me to give serious consideration to using your portal product, and JBoss products in general, for development on behalf of my customers. I'm not doing a school project here...

                                    -Dave

                                    1 2 Previous Next