13 Replies Latest reply on Jul 26, 2005 1:33 PM by mholzner

    what is the recommended way to reuse/extend default jboss po

      Hi,

      I am setuping my own web site based on jboss portal 2.0.

      I want to reuse jboss portal portlets such as user, admin and cms etc.

      It seems that there are two ways:
      (1)Setup ant build files from scratch and reuse Java codes by importing related jars into my own portal project. For this way, which jars should i imported?

      (2)Focusing on the extending/modifying xml files such as default-portal, -pages.... etc and reusing jboss build system. For this way, it seems simple but difficult to maintain.

      Any document guild?

      thanks a lot

      Yang

        • 1. Re: what is the recommended way to reuse/extend default jbos

          I think i should ask question in another way.

          Is it better to divide jboss-portal.sar into two parts. One is portal server and the other is default jboss portal application? Third party developer can develope their own portal by following jboss portal application.

          regards

          Yang

          • 2. Re: what is the recommended way to reuse/extend default jbos

            is it possible to use layout/theme api to customize a layout similar to nodesk layout?

            After i read some of the jboss portal code, a few renders are provided. But it seems that none of them can be used to render a complex layout/theme.

            Is it possible to have a render just read a modified nodesk layout(e.g. index.jsp) jsp file ?

            regards

            Yang

            • 3. Re: what is the recommended way to reuse/extend default jbos

              Hi

              I try to reuse theme and layout from my old project which are jsp file and css file.

              Because the layout jsp file include some complex decorations like nodesk, it seems i need to write my own render classes.

              However, i am not familiar with render classes and how it works.

              I am wondering whether it is possible to use following way:

              (1)modify my existing layout file by using theme and region tag.
              (2)Using Region API to get Item objects
              (3)From Item, FragmentResult object can be gotten.
              (4)In layout jsp file, write decorations into FragementResult.getWriter() directly.

              Although i know this won't work because there is no APIs to seperate the content and decoration for FragementResult. If this way work, is it simple?

              regards

              Yang

              • 4. Re: what is the recommended way to reuse/extend default jbos

                don't change the fragment generation.
                We introduced the render set for what you are describing here.

                A render set consists of the implementations of 4 interfaces:
                (all in org.jboss.portal.server.theme.render.*)
                - RegionRenderer
                - WindowRenderer
                - DecorationRenderer
                - PortletRenderer

                look at the provided implementations (divRenderer, tableRenderer, and emptyRenderer for an example).

                You can set the render set as a portal property (look at default-portal.xml):

                org.jboss.portal.property.renderSet
                [your render set here]


                you can define your render set implementation in a render set descriptor (portal-renderSet.xml) that needs to live in the WEB-INF/layout folder of any of your deployed webapps.

                think of a render set as the containers that wrap the portlet content. the PortletRenderer can be used to wrap the markup that was generated by the portlet itself, the DecorationRenderer generates the window title and the mode and state links, the WindowRenderer generates the markup for one portlet window (usually including the output of PortletRenderer and DecorationRenderer), and the RegionRenderer is used to wrap the markup of several portlet windows .

                • 5. Re: what is the recommended way to reuse/extend default jbos
                  wlchung

                  Do you mean we can add renderSet by adding a portal-renderSet.xml to
                  the WEB-INF/layout folder of my portlet app? I try to add a renderSet this way with the 4 components pointing to different combination of the existing renderers, say from emptyXXX and divXXX. However, when I deploy the portlet, it gave me the stack trace or no effect.

                  The reasons are
                  1) I do not know the name of the renderSet that will be pickup by default. Had try to use "default" but no effect. The only location that I think we can specify the renderSet to use is the portal level default-portal.xml file
                  2) If I give it the same name as in the portal-core default-portal.xml, there is not effect too. So this locally defined renderSet had not overridden the portal default.
                  3) I see from this forum that the reference to the portal-renderSet.xml sometimes refer to the WEB-INF/layouts (with an "s"). Which one is correct? I cannot find the code that doing the loading.

                  Thanks

                  wl

                  • 6. Re: what is the recommended way to reuse/extend default jbos

                    yes, adding a portal-renderSet.xml to your apps WEB-INF/layout folder will introduce this render set to the portal. any portal can then point to that render set via the mentioned portal property (see first response in this thread).

                    re 1) the name of the render set to use for a portal is defined in the portal properties (see earlier)
                    re 2) I haven't tested what happens when you 'overwrite' the render sets defined in the core. You should definitely use your own name.
                    re 3) it's WEB-INF/layout/portal-renderSet.xml (the folder and file name is singular)

                    again, the portal property and the render set name have to match:

                    <?xml version="1.0" encoding="UTF-8"?>
                    <portal-renderSet>
                     <renderSet name="myRenderer">
                     <set content-type="text/html">
                     <region-renderer>org.jboss.portal.theme.impl.render.DivRegionRenderer</region-renderer>
                     <window-renderer>org.jboss.portal.theme.impl.render.DivWindowRenderer</window-renderer>
                     <portlet-renderer>org.jboss.portal.theme.impl.render.DivPortletRenderer</portlet-renderer>
                     <decoration-renderer>org.jboss.portal.theme.impl.render.DivDecorationRenderer</decoration-renderer>
                     </set>
                     </renderSet>
                    


                    defines a render set with the name 'myRenderer'

                    <?xml version="1.0" encoding="UTF-8"?>
                    <portal>
                     <portal-name>default</portal-name>
                     <properties>
                     ....
                     <property>
                     <name>org.jboss.portal.property.renderSet</name>
                     <value>myRenderer</value>
                     </property>
                     ....
                    


                    is a portal property that points the portal to use this render set.

                    Currently a render set can only be defined at the level of a portal and a layout. Each layout can define its own renderset. Each page could define its own layout. So theoretically, you could have a different render set for every page.


                    The reason why you don't see a difference is that you probably test this with the default portal and default page. This scenario currently doesn't use the render set, but rather the basic tag lib to render the markup.
                    The render set works together with the region and portlet tags.


                    • 7. Re: what is the recommended way to reuse/extend default jbos

                      Martin,

                      I'm interested in creating my own version of org.jboss.portal.theme.impl.render.DivDecorationRenderer

                      Then I'm guessing I would change portal-renderSet.xml:
                      <decoration-renderer>org.slholmes.MyDivDecorationRenderer</decoration-renderer>

                      Is it intended that developers can create our own Java class for this? I'd like simply to change the markup for the title line of the portlet.

                      Scott

                      • 8. Re: what is the recommended way to reuse/extend default jbos

                        yes, this is intended to be used and altered by developers. I just haven't gotten around to provide proper documentation. We also kept it a bit in the closet since we still try to figure out the correct connection to themes. My 'perfect world' would look like this:
                        the render set generates a set of xhtml tags with well known class and id attributes. the theme would match on those classes and attributes . This would give us a portable theming / skinning model where skins (themes) can be freely exchanged and swapped on the fly. For that to work, we need to define the correct set of classes and ids that every theme has to follow. Since I'm not a web designer, I'm depending on input from others for this. Unfortunately, my designer friends here have lots of ideas, but still no time. .... long story, sorry ;) ...

                        back to reality: you can change the existing render set in the core, or provide your own. render sets can be deployed independent of other portal artifacts, so you could wrap one in a war and deploy it, the portal will pick it up (as long as you provide the /WEB-INF/theme/rendetSet.xml descriptor)

                        • 9. Re: what is the recommended way to reuse/extend default jbos

                          Ok, good. I'd already started a project in Eclipse to start on this.

                          It's interesting that you mention "ID". In muling over my "perfect world", I'd thought that it would be clever to attach an ID attribute to everything - but in thinking about the CSS involved, this ID would necessarily need to include at least some kind of portlet unique identifier. IDs must be unique within an XHTML document so the Portlet name and some other descriptor would not be enough if you're site-ing multiple copies of a portlet on a page.

                          So now I'm thinking that Class might be enough.

                          Feedback: In attempting to keep structure separate from presentation, DivDecorationRenderer is sending the title line of the portlet out as a Table. While technically this is OK, I'm worried about the semantic meaning of the table - it's a bit of a stretch and seems like we're using tables for Layout which is a no-no in this respect.

                          More Feedback: Would not JSP tags work better for the renderer bits? I'm not that experienced with all this technology yet, but requiring JAVA impletementations seems pretty heavy - Everything else is JSP (well except the actual fragments).

                          • 10. Re: what is the recommended way to reuse/extend default jbos

                            I see ID attributes for things that are truly unique in the document, everything else should be a class.

                            the table in the divDecoration renderer is a total hack, I know. What I wanted is the css zengarden approach, but again, that's where I need the web designers of this world to help me out. It isn't that simple as I found out ;)

                            I agree, this should all be in tags, and it fact it is! The entire idea of the render set was to abstract the common stuff away, and surface it via a jsp tag and an API (for those servlet lovers). What I didn't do (and what you're probably hinting at) is provide a region, a window, a decoration and a portlet content tag that work together just like the render set. I chose to offer the region tag, and let the rendet set do the rest. However it would be easy to write those other tags. I didn't want to expose too many ways for the same functionality, but perhaps the way I chose is the wrong one.

                            • 11. Re: what is the recommended way to reuse/extend default jbos

                              You know, I'm re-reading this and I'm liking more the idea of keeping the "layout" of the document out of reach of the web designer, i.e. jsp/CSS.

                              If you want an easy to use themeing system, you probably should keep that in a Java class and keep it as an "Advanced" topic.

                              I was thinking that if I spend a bunch of time creating a theme - and I want to share with other portal users - we're sunk if I mess about with the classes in any non-trivial way.

                              What I'll do is play around with some alternative markup for the title and post some ideas here for public review.

                              • 12. Re: what is the recommended way to reuse/extend default jbos
                                wlchung

                                mholzner,

                                I have not been clear in the previous posting. What I wondered was if it was possible to have portlet-level renderSet (not portal-level). I thought it was possible to deploy a portlet (app) with the WEB-INF/layout/portal-renderSet.xml file and made it the default renderSet for that particular portlet. (That explains those questions I asked) Your reply clear things up though.

                                "mholzner" wrote:


                                Currently a render set can only be defined at the level of a portal and a layout. Each layout can define its own renderset. Each page could define its own layout. So theoretically, you could have a different render set for every page.




                                I find things get complex again when 'back to reality'.

                                "mholzner" wrote:


                                back to reality: you can change the existing render set in the core, or provide your own. render sets can be deployed independent of other portal artifacts, so you could wrap one in a war and deploy it, the portal will pick it up (as long as you provide the /WEB-INF/theme/rendetSet.xml descriptor)


                                Does that mean we can deploy renderSet by 2 methods.
                                1) /WEB-INF/layout/portal-renderSet.xml
                                2) /WEB-INF/theme/renderSet.xml (spell correct?)

                                Any differences between these 2?


                                On separate presentation and renderers. It is good. However I encounter a lot of problems related to applying the presentation to the result of my custom renderer. One major problem took me more than 2 days (still on it) is different browers behave differently, in my case with img.


                                wl

                                • 13. Re: what is the recommended way to reuse/extend default jbos

                                  sorry for the confusion! There is only one place for custom render sets to be picked up in an application:

                                  /WEB-INF/layout/portal-rendetSet.xml

                                  /WEB-INF/theme/* is wrong !