3 Replies Latest reply on Apr 26, 2007 8:19 AM by lindsayh

    how do i get the size of collection in .xhtml with facelets

    holtak

      hello

      how do I get the size of a collection in .xhtml when using facelets?

      what I want to do is something like this
      <h:outputText value="#{myBean.myCollection.size}"/>

      thanks

        • 1. Re: how do i get the size of collection in .xhtml with facel
          msduk

          Are you susre that your collection supports getSize() ?

          Iterator and a few others do not

          • 2. Re: how do i get the size of collection in .xhtml with facel
            pmuir

            Seam intercepts EL calls and adds in a size property for Collections, Map and DataModel. Does this work if your EL expression is #{myCollection.size}?

            • 3. Re: how do i get the size of collection in .xhtml with facel
              lindsayh

               

              "petemuir" wrote:
              Seam intercepts EL calls and adds in a size property for Collections, Map and DataModel. Does this work if your EL expression is #{myCollection.size}?


              I think these EL resolvers only work for JSF 1.2.

              After having difficulty getting my app to work with JSF 1.2, I just use the JSTL length funtion to get a collection size when I need to:

              Here's my namespace declaration:

              <ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
               xmlns:s="http://jboss.com/products/seam/taglib"
               ...
               xmlns:jstlfn="http://java.sun.com/jsp/jstl/functions"
               ...
              


              and here's how I use the length function in a table:

              <rich:column>
               <f:facet name="header">
               No. of Users
               </f:facet>
               #{jstlfn:length(userGroup.users)}
              </rich:column>
              


              I got this tip from someone else.

              Lindsay