5 Replies Latest reply on Oct 7, 2009 10:41 AM by vgarmash

    rich:dataTable sorting makes direct HttpServletRequest under

    vgarmash

      Hi there!

      I discovered interesting issue but probably it is a feature. I found that even inside portlet (JBoss Portal) with configured JBoss Portlet Bridge sorting links are sending reqular HTTP requests to the application. In other words sorting links (and probably filtering ones too) are not being wrapped into portlet links. As the result table re-rendering is done though direct call to application instead of going though portal.

      For most cases it is sufficient but there are couple cases when it can cause troubles. In my case I found impossible to use EL function that filters access to certain command links by calling request.isUserInRole from the page. This is because under Jboss Portal only PortletRequest instance will work. HttpServletRequest will always return false.

      To confirm that rich:dataTable use different type of request for initial rendering and sorting you can use simple code snippet:

       <rich:dataTable value=#{myBean.list} var="r">
       <rich:column sortBy="#{r.name}">
       <f:facet name="header">Name</f:facet>
       <h:outputText value="#{r.name}" />
       </rich:column>
       <rich:column>
       <f:facet name="header">Request</f:facet>
       <h:outputText value="#{request.class}" />
       </rich:column>
      </rich:dataTable>
      


      For that you of course will need to define some managedBean with getList() getter that will return list of objects.
      In my case test table looks like this after initial rendering:
      [img]http://www.vgarmash.narod.ru/images/errors/initialTable.png[/img]
      And like this after sorting:
      [img]http://www.vgarmash.narod.ru/images/errors/afterSorting.png[/img]

      I found this issue when I tried to use EL function to call request.isUserInRole. Finction specified in Facelets config like this (this is 3rd variant, 1st one used PortletRequest type for second attribute):
       <function>
       <function-name>isUserInRole</function-name>
       <function-class>com.sensei.auth.functions.SecurityCheckFunctions</function-class>
       <function-signature>boolean isUserInRole(java.lang.String, java.lang.Object)</function-signature>
       </function>

      Java class for tat function:
      public class SecurityCheckFunctions {
      
       private static final Logger logger = Logger.getLogger(SecurityCheckFunctions.class);
      
       public static boolean isUserInRole(String roleName, Object requestObject) {
       boolean userInRole = false;
       if(requestObject instanceof PortletRequest) {
       PortletRequest request = (PortletRequest) requestObject;
       logger.debug("request is PortletRequest");
       userInRole = request.isUserInRole(roleName);
       } else if(requestObject instanceof HttpServletRequest) {
       HttpServletRequest request = (HttpServletRequest)requestObject;
       logger.debug("request is HttpServletRequest");
       userInRole = request.isUserInRole(roleName);
       }
      
       logger.debug("test isUserInRole("+roleName+") = "+userInRole);
       return userInRole;
       }
      }
      

      Usage example:
      <h:commandLink ... rendered="#{!res.published and nutri:isUserInRole('Nutrition Administrator', request)}"/>


      Currently this EL function works only during initial page rendering. If I click sorting on any column, my function always return false because type of request is not PortletRequest.

      My question is: is described rich:dataTable behavoir is valid or it should be fixed as a bug?

        • 1. Re: rich:dataTable sorting makes direct HttpServletRequest u
          ilya_shaikovsky

          after review we belive that this should be adressed to portlet bridge team. forwarded your report. thanks!

          • 2. Re: rich:dataTable sorting makes direct HttpServletRequest u
            vgarmash

             

            "ilya_shaikovsky" wrote:
            after review we belive that this should be adressed to portlet bridge team. forwarded your report. thanks!

            Thank you, Ilya for so quick response. Actually this is combined issue because it is not clear if Portlet Bridge team should modify the source code of RichFaces custom components. I am not familiar with sources but if rich:column implementation is not designed to work together with portlet bridge (in other words: all generated links are hardcoded to make direct calls) then the bridge team can't fix it.

            • 3. Re: rich:dataTable sorting makes direct HttpServletRequest u
              ilya_shaikovsky

              Response from Alex(portlet bridge core developer):


              This is correct for portletbridge 1.0 that wraps JSF applications as JSR-168 portlets. Because portlet 1.0 does not define special links for AJAX/resource requests, there was the only way to make these request directly to web application.
              Portletbridge 2.0 is based on the JSR-286/JSR-301.2 API and uses Portlet ResourceRequest to perform AJAX calls and render portlet resources, so all links in the bridge 2.0 application are portal links.
              P.S. In the non-ajax mode, all links should be pointed to portal.


              • 4. Re: rich:dataTable sorting makes direct HttpServletRequest u
                vgarmash

                Thank you for this response. Seems like we need to consider upgrade of out portletbridge to ver. 2.0 or use alternative way to resolve security rules.
                By the way I think this is important feature of Portletbridge 1.0 and if you can put it into the documentation then other people will be aware about it.
                Thanks again. Bye!

                • 5. Re: rich:dataTable sorting makes direct HttpServletRequest u
                  vgarmash

                   

                  "vgarmash" wrote:
                  By the way I think this is important feature of Portletbridge 1.0 and if you can put it into the documentation then other people will be aware about it.
                  Thanks again. Bye!

                  I found another topic with similar question: http://www.jboss.org/index.html?module=bb&op=viewtopic&t=160481
                  So it is surely will help people better understand Portlet Bridge implementation if you add some notes into documentation.