4 Replies Latest reply on Jul 10, 2006 4:41 PM by icewolf20

    Doc/Info on HOW JPortal is Implemented?

    icewolf20

      Alrighty, time to swallow some pride. I've been working in a portlet environment for some time now, using the Jetspeed 1.x portlet container. I'm attempting to make the switch from Jetspeed to JPortal to make things easier for our AS managers, but making the coding switch from Jetspeed to JPortal is proving to be more...complex than origionally thought. Basically, what I'm looking for is a "how to" for JPortal insomuch as the portal to portlet building is concerned.

      I've refreshed myself with the Portlet specification, and in doing so realized that JPortal is more closely tied to the specification than Jetspeed was (missing quite a few layers of middleware [Torque/Turbine]). If I can be pointed to a general implementation doc and save people the trouble of doing a point-by-piont, it would be appreciated. I've hammered the docs and the examples, but yet I cannot get a grip on how JPortal would implement something as Jetspeed does:

      1. I'd like to use JSP's to create the portlets, but I cannot find a mechanism for binding a JSP to a portlet class. The examples only show two ways that I've found--directly building the page in a writer on the reponse object, or referencing a JSP directly in the doView through the requestDispatcher. Is there a way in JPortal to directly map a JSP to a class as there is in Jetspeed with the MyPortlet.xreg (register and binds all Action classes to JSP's).

      2. Jetspeed relied heavily on the request and session parameters comming from the portlet/portal. The methods of the JBossPortlet do make use of request variables that have attributes. Does JPortal use the request variable to pass parameters BACK to the JSP for building the page? For example, if I have a portlet that I want to display (for the sake of argument) a list of all the records in a table. I'd have the doView() method call a back end hibernate method to query the database and return a list of records. I would then set a request variable, giving it the value of the returned list, and then on the JSP use a <c:forEach> tag to print out the values as specified by the Value Object of that class. Can this same methodology be applied to a JPortal portlet? Can I use request variables of lists from the database to build a JSP?

      3. When processing an action from the portlet, be it from a hyperlink or a button, how do I get the Action class to execute a specific method? In jetspeed, if I wanted a "doSomeaction()" method to be executed in the Action class bound to the JSP, I'd have to give the name of the button (or hidden parameter) a name like "eventSubmit_doSomeaction", and that method would be executed on form submission/button click. How can I get JPortal to execute a specific method inside the Action class without having to parse through the expected parameters from the portlet inside the processAction class (if at all)?

      I apologize for the lengthy questions and examples, but I really need to get a better grasp on how JPortal functions and get my mind off of Jetspeed and around a much better solution. Thanks in advance for any help and direction.

        • 1. Re: Doc/Info on HOW JPortal is Implemented?

           

          "IceWolf20" wrote:
          Is there a way in JPortal to directly map a JSP to a class as there is in Jetspeed with the MyPortlet.xreg (register and binds all Action classes to JSP's).


          No, and I'm not familiar with why or how this works in JS. Makes as much sense as binding a JSP to a Servlet.

          "IceWolf20" wrote:
          Can this same methodology be applied to a JPortal portlet? Can I use request variables of lists from the database to build a JSP?


          Yes. Set your List as a parameter and retrieve if in the JSP.

          class:
          request.setAttribute("somelist", someList);
          
          jsp:
          List blah = (List) request.getAttribute("somelist");
          


          "IceWolf20" wrote:
          How can I get JPortal to execute a specific method inside the Action class without having to parse through the expected parameters from the portlet inside the processAction class (if at all)?


          You can't. All actionUrls post to the processAction, and from there you call your specific method.

          You mention "Action Class" a lot. Not sure if you mean the actual portlet class, or some other thing thats JS specific.


          • 2. Re: Doc/Info on HOW JPortal is Implemented?
            bdaw

            Ad. 2) I'm not sure if I understand your question well. You can simply use and access most of portlet objects from JSP.
            You can also pass your objects to jsp within a session or using RenderRequest.setAttribute (set object in portlet and get in jsp/servlet).

            Ad. 3) You can do such thing if you extend JBossPortlet (instead of GenericPortlet). You pass method name which should be invoked in action phase as request parameter - default param name is "op" but it can be changed by overwriting .getDefaultOperation() method

            Generally some more advenced stuff can be used when you extend JBossPortlet instead of GenericPortlet.

            Look at ForumsPortlet class in forums module in portal sources.
            You can easily pass things into jsp using custom taglib.

            For example you do:

            1) in portlet you fill DelegateContext object with your data - which have nested structure
            2) you dispatch with passing DelegateContext to JSP like:

            req.setAttribute(PortalJsp.CTX_REQUEST, delegateContextObject);
            PortletRequestDispatcher rd = getPortletContext()
            .getRequestDispatcher("yourJSPFile.jsp");

            3) In your JSP you can use a set of tags to get data from DelegateContext object like:

            <n:if/>
            <n:include/>
            <n:iterate/>

            all of those are implemented in org.jboss.portal.core.servlet.jsp.taglib.* package

            If you want to investigate it more just analize ForumsPortlet doView() method. RolePortlet and UserPortlet uses this stuff as well




            • 3. Re: Doc/Info on HOW JPortal is Implemented?
              bdaw

              but remember that JBossPortlet stuff extends the spec so you always lose portability of your portlet.

              • 4. Re: Doc/Info on HOW JPortal is Implemented?
                icewolf20

                Thanks for the info..."Action class" is a reference to the hierarchy of classes within the framework:

                JSP -> Action Class -> Business Object -> Data Access Object -> Value Object (deprecated) -> Hibernate Mapping

                The "Action class" in my context is simply the term I used for the class that (in Jetspeed) indirectly implements (through turbine) the GenericPortlet class. It has a method called "buildNormalContext" that must be defined in the class that JspPortletAction class that functions like the "doView" method does in JPortal. Essentially "Action class" in JPortal is the class that extends the JbossPortlet class.