5 Replies Latest reply on May 29, 2012 9:56 PM by hoang_to

    Display the groupId in the bannerPortlet

    nadiaperez

      Hi All,

       

      We are using Gatein3.2 to create a customized portal. We need to display on the banner the userId and the list of groupId of a user.

       

      To do so, we have added some code on the BannerPortlet, but it generates an error

       

      def membership = uicomponent.getMembership(); // this line generates an error

       

      <table>

           <%

                          String rowClass = null;

                          boolean even = true;       

                          //TODO:    Do not use the    syntax

                          membership.eachWithIndex() {                           

                              member, i ->   

                              if(even) rowClass = "OddRow";

                              else rowClass = "EvenRow";

                                  even = !even;

                      %>

                              <tr class="<%=rowClass%>">

                                  <td>$member.groupId</td>

                              </tr>

                      <%}%>

      </table>

       

      Do you have any suggestion to fix this?

       

      Thanks

        • 1. Re: Display the groupId in the bannerPortlet
          haint

          Did you import org.exoplatform.services.organization.Membership in template ?

          • 2. Re: Display the groupId in the bannerPortlet
            nadiaperez

            Thanks for your answer, I have actuyally added  import org.exoplatform.webui.organization.UIGroupMembershipSelector;

             

            and I just tryed by importing org.exoplatform.services.organization.Membership

             

            And I still got an error :

            Caused by: groovy.lang.MissingMethodException: No signature of method: org.exoplatform.portal.webui.application.UIGroovyPortlet.getMembership() is applicable for argument types: () values: []

                    at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:54)

                    at org.codehaus.groovy.runtime.callsite.PojoMetaClassSite.call(PojoMetaClassSite.java:46)

                    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:40)

                    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)

                    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:120)

                    at UIBannerPortlet.run(UIBannerPortlet.gtmpl:41)

                    at org.exoplatform.groovyscript.GroovyScript.render(GroovyScript.java:111)

                    ... 204 more

             

            Maybe some other suggestion?

            • 3. Re: Display the groupId in the bannerPortlet
              haint

              Where did you declare getMembership() method ? I see only getListMembership() in UIGroupMembershipSelector

              • 4. Re: Display the groupId in the bannerPortlet
                kien_nguyen

                To get groups of user, you can use service OrganizationService:

                import org.exoplatform.services.organization.OrganizationService;

                 

                def service = uicomponent.getApplicationComponent(OrganizationService.class);

                Collection groups = service.getGroupHandler().findGroupsOfUser(userId);

                Also, you can get userId from request context:

                def userId = prContext.getRemoteUser();

                • 5. Re: Display the groupId in the bannerPortlet
                  hoang_to

                  It's important to keep in mind that the variable 'uicomponent' refers to the UI component associated with rendering template. As Hai mentionned that the method getListMembership() in UIGroupMembershipSelector, you could invoke this method only in Groovy template of UIGroupMembershipSelector.