1 2 Previous Next 19 Replies Latest reply on Aug 21, 2007 6:04 PM by krish p

    Configuring JBoss Portlets by default

    krish p Novice

      Hi,
      If I want to add a bunch of (custom) Portlets by default when the user accesses the main page (as the "configure" page is hidden), how would I do that? Which of the portal tables do I need to seed? I see a number of tables that are updated when a portlet is added and I want to do this via a script at startup, or declaratively, somehow. Thanks.

        • 1. Re: Configuring JBoss Portlets by default
          Peter Johnson Master

          You did not state which version of the Portal you are using so I will assume 2.6.x.

          The base page for the portal is given by the file jboss-portal.sar/conf/data/default-object.xml. If you examine this file, you will see that it declares the base portals but only the home (default) page on the default portal.

          So where does, for example, the weather page and its portlet come from? It is declared in jboss-portal.sar/sample/portal-weather-samples.war/WEB-INF/default-object.xml. The news page is similarly declared. Follow those examples to add your own pages, or your own portlets to the home page.

          • 2. Re: Configuring JBoss Portlets by default
            krish p Novice

            Thanks PeterJ. I found 1 occurrence of the default-object.xml file in the JBoss folder. Making any changes to that file doesn't seem to make any difference to the list of portlets displayed on the default page..

            Is there something else I need to look at? Thanks.

            • 3. Re: Configuring JBoss Portlets by default
              Peter Johnson Master

              The portlet information is stored in the database. Changing the default-object.xml file to remove portlets does not work, unless you reinitialize the database (that is, start over from scratch). You can, however, add new portlets by adding them to default-object.xml.

              If you do not want to reinitialize the database, you could always use the Admin portal to change the default page. For example, you could delete the portlets you no longer want.

              • 4. Re: Configuring JBoss Portlets by default
                krish p Novice

                Okay, thanks PeterJ. You've confirmed my suspicion. That's how I thought it probably worked but was a little puzzled by what i saw - when I tried to wipe out the only portlet entry in that file and re-started JBoss, it seemed to not render any portlet at all. Maybe, something else is going on here (will start from scratch again by creating a new db). Since i am doing some new development, it is a little hard to re-create the DB each time (dont have the handy ANT targets yet to drop/re-create new JBoss Portal schemas).

                Thanks for your pointers. Appreciate it!

                • 6. Re: Configuring JBoss Portlets by default
                  krish p Novice

                   

                  <page>
                   <page-name>default</page-name>
                   <window>
                   <window-name>AdminPortletWindow</window-name>
                   <instance-ref>AdminPortletInstance</instance-ref>
                   <region>center</region>
                   <height>0</height>
                   </window>
                   <window>
                   <window-name>AdminPortletWindow</window-name>
                   <instance-ref>PortletInstance2</instance-ref>
                   <region>center</region>
                   <height>0</height>
                   </window>
                   </page>


                  I added the second portlet instance. Now, the first one doesn't show up? What am i doing wrong?

                  • 7. Re: Configuring JBoss Portlets by default
                    Peter Johnson Master

                    Did you also declare the instance in the appropriate portlet-instances.xml file? The *-object.xml file is not used to declare instances, only to reference them to define the portal and page contents.

                    • 8. Re: Configuring JBoss Portlets by default
                      krish p Novice

                      Yes, I've added these portlets to portlet.xml and portlet-instances.xml as well. I know that they are available as I am able to add them through the UI. However, I want to add these declaratively so that they show up by default. Plus, we don't want to allow our users to remove these portlets so UI is not an option.

                      • 9. Re: Configuring JBoss Portlets by default
                        krish p Novice

                        Almost missed that post. Thanks for your build script. Let me take a look at that!

                        • 10. Re: Configuring JBoss Portlets by default
                          krish p Novice

                          Also, I am almost certain that there is something not quite right with the entry I added to the default-object.xml file. It doesn't complain when JBoss starts up but I have a feeling it is not quite right.

                          • 11. Re: Configuring JBoss Portlets by default
                            Peter Johnson Master

                            Double-check the spelling on the instance name in both portal-instances.xml and *-object.xml. Misspelling is usually what trips me up.

                            Also, does the portlet window show up in the list of portlet windows for that page in the Management Portal. If you click on the portlet window there, and the lists of instances displayes, is the correct instance highlighted. If nothing is highlighted, then the instance name must be wrong (happened to me just last weekend).

                            Also, are you modifying the jboss-portal.sar/conf/data/default-object.xml file? If so, then your portlets must be deployed within the jboss-portal.sar directory. The other option is to add your portlets to the default portal page using the *-object.xml file bundled with your portlets.

                            • 12. Re: Configuring JBoss Portlets by default
                              krish p Novice

                              I am editing the default-object.xml file bundled with my portlets. I've verified that this file gets picked up now.

                              This is how my entry looks in portlet-instances.xml -

                              <deployment>
                               <instance>
                               <instance-id>SomePortletInstance</instance-id>
                               <portlet-ref>SomePortlet</portlet-ref>
                               </instance>
                               </deployment>


                              ..and this is how my entry in the default-object.xml looks like:

                              <security-constraint>
                               <policy-permission>
                               <action-name>viewrecursive</action-name>
                               <role-name>Admin</role-name>
                               </policy-permission>
                               </security-constraint>
                               <page>
                               <page-name>default</page-name>
                               <window>
                               <window-name>AdminPortletWindow</window-name>
                               <instance-ref>SomePortletInstance</instance-ref>
                               <region>center</region>
                               <height>0</height>
                               </window>
                               </page>


                              • 13. Re: Configuring JBoss Portlets by default
                                krish p Novice

                                 

                                <page>
                                 <page-name>default</page-name>
                                 <window>
                                 <window-name>AdminPortletWindow</window-name>
                                 <instance-ref>SomePortletInstance</instance-ref>
                                 <region>center</region>
                                 <height>0</height>
                                 </window>
                                 </page>


                                If I add 2 blocks of this, only the second one is added. Verified the JBP_WINDOWS table. However, though I see an entry in this table for the now-modified entry in default-object.xml, nothing really shows up in the UI unless I do this action in the UI.

                                Finally, I see multiple deployment elements in default-object.xml. I am just adding my entry to the last one. Perhaps that is where the problem is?

                                • 14. Re: Configuring JBoss Portlets by default
                                  Peter Johnson Master

                                  I think you need to post the whole portlet-instances.xml and default-object.xml files.

                                  1 2 Previous Next