11 Replies Latest reply on Feb 10, 2011 3:42 AM by freak2051

    UITabContainer question (Book in GateIn)

    freak2051

      Hi,

       

      I have this situation:

       

      1)          There is portal page with one main portlet let’s call it Portlet 1 (Master) and many slave portlets which depend on Portlet 1. On Portlet1 user can search for entities and when selects some one then JSR-286 events are sent to many depending portlets for updating view (usually with id’s or another identification data). Depended portlets are basically just showing different piece of data  of main entity. Please see attachment.

       

       

      1)          There is portal page with one main portlet let’s call it Portlet 1 (Master) and many slave portlets which depend on Portlet 1. On Portlet1 user can search for entities and when selects some one then JSR-286 events are sent to many depending portlets for updating view (usually with id’s or another identification data). Depended portlets are basically just showing different piece of data  of main entity. Please see the picture at the end.

      2)          In Gatein I use UITabContainer for holding depended portlets and from UI point of view everything looks like good.

       

      3)          But performance is really poor because UITabContainer processes every tab with all portlets every action/render request. I guess this is because switching tabs is happening  on client via Javascript so complete container must be processed.

      Question:

      Can I change this default behaviour for another (sent complete new request after switching tab) ? And how to do it? After this change the performance issue should be gone because only tab what is selected (and shown) is also processed.

       

      Note 1:

      I switched from Oracle Portal and there is top component called “Book” for it. And it behaves exactly as I need and it’s most logical. I didn’t realize that can be even different in UITabContainer (or at least should configurable). 

       

      Note2:

      I can’t use much different approach like pages because you can’t sent events across pages in Gatein and basically I need exactly UITabContainer but with different behavior.

       

      Note3:

      I tried some change in UITabContainer.gtml groovy template but I suppose that you can only influence rendering but not processing (all needed logic including portlets) of tabs.

       

      thanks for any ideas.

        • 1. UITabContainer question (Book in GateIn)
          sowa

          Hi,

           

          It seems that I have exactly the same problem - I don't want to render all tabs - just the selected one.

          So far I didn't find any useful information, let's hope that someone on this forum will have some idea.

           

          Best regards,

          Sowa

          • 2. UITabContainer question (Book in GateIn)
            rraposa

            Is there a way for you to determine in your portlet code which tab is currently selected? If yes, then in your render() method, simply return without rendering the portlet's view.

             

            For example, if your portlet is on the "MyTab" tab:

             

            public void render(...) {

                if(!selectedTab.equals("MyTab") {

                      return;

                } else {

                      //render the portlet's view

               }

            }

             

            Can you obtain a reference to the UITabContainer object somehow in your portlet? If not, then you can write an EventListener that keeps track of which tab is currently selected.

            • 3. Re: UITabContainer question (Book in GateIn)
              freak2051

              Thanks for reply.

               

              I didn't mention before but I am using standard JSR-286 portlets and Spring PortletMVC framework. So it could be possible stop processing whole portlet there e.g using filters or interceptors. But real mystery is the eXo container UITabContainer. I have no idea how I can override default behaviour. There is no single example in GateIn or even eXo documentation. Only thing that I can change is groovy template (UITabContainer.gtml) but as I said in original post (Note 3) I suppose that you can only prevent displaying tab or change look and feel of container. It's just template.

              • 4. UITabContainer question (Book in GateIn)
                sowa

                Clear thing is that I need to prevent rendering porlets which are not on selected tab.

                So real question is how to check from portlet controller code which one tab is selected and which ones portlets are currently on that tab.

                • 5. UITabContainer question (Book in GateIn)
                  rraposa

                  At the end of UITabContainer.gtmpl, there is a for loop that renders each child container on a tab. Notice how the template uses the "display:none" CSS style to hide the unselected tabs:

                   

                          <%            

                              for(uiChild in uicomponent.getChildren()) {

                                  String status2 = "none";

                                  if(uiChild.isRendered()) status2 = "block";

                          %>

                                  <div class="UITabContent" style="display: <%=status2%>;">

                                          <% uicomponent.renderUIComponent(uiChild);%>                

                                  </div>

                          <%

                              }

                          %>

                   

                  Try *not* rendering each child component, but only the selected one instead. For example, replace uicomponent.renderUIComponent(uiChild) with:

                   

                  if(uiChild.isRendered()) {

                      uicomponent.renderUIComponent(uiChild);

                  }

                   

                  See what affect that has on the behavior of the tab container.

                  • 6. UITabContainer question (Book in GateIn)
                    sowa

                    Hey, that can be solution

                    I was worried that this renderUIComponent() method is responsible just for 'drawing' portlet which already has been processed, but actually I find out that UIComponent in renderUIComponent() method is actually calling processRender() method for portlet.

                    I will check this solution and let you know about the results.

                    • 7. UITabContainer question (Book in GateIn)
                      rraposa

                      Sowa - let me know if that trick worked.

                      • 8. UITabContainer question (Book in GateIn)
                        freak2051

                        Hi again,

                        Please think about it more. Even when you make it - stop rendering non-selected tabs what will you get? Now complete container is processed and you can switch the tabs on client via JS. When they aren't rendered, what will you get after tab switching? Just blank tab....no only way is send new request with "request for update selected tab". And that means like creating whole new type of container?

                        What they were thinking!  

                        • 9. UITabContainer question (Book in GateIn)
                          rraposa

                          Good to know. We need each tab's corresponding container created.

                           

                          Then you will have to refer back to my original answer. You need to figure out which tab is currently selected, then have the render() method simply return (without sending anything in the response) if the portlet is not on the currently selected tab.

                           

                          By the way, you are creating a new type of container with this behavior, so don't be surprised if you end up modifying/extending the source code somewhere! GateIn does not appear to have an equivalent container similar to the Book container of Oracle Portal.

                          • 10. UITabContainer question (Book in GateIn)
                            rraposa

                            John - you will also need to add to the JavaScript code behind the scenes to fully implement the behavior that you want. If you are not going to render each tab container initially, then when a user clicks on a new tab, an Ajax request will need to be sent to the portal telling it to redraw that container. This would be non-trivial, because you will have to send that Ajax request to each portlet on that particular tab.

                             

                            I'm guessing the easiest way to implement this is to write a new class that extends UITabContainer. It would be a nice addition to GateIn for anyone who has time to figure this out.

                            • 11. UITabContainer question (Book in GateIn)
                              freak2051

                              Yes, I tried to create new container UILazyTabContainer but without any reasonable documentation I failed of course. Even there is already UILazyTabPane component in webuUI core you apperantly can't use it as container. So only hope is JBOSS itself. There are two issues related it so please vote for it. Thanks a lot!

                               

                              https://jira.jboss.org/jira/browse/GTNPORTAL-1788

                              https://issues.jboss.org/browse/JBEPP-793