7 Replies Latest reply on Sep 29, 2006 5:08 PM by gavin.king

    rowCount

    kh2ouija

      I use rowCount to get a collection's size, like this:

      <ui:repeat value="#{departments}" var="department" rendered="#{departments.rowCount > 0}">
       <h:outputText rendered="#{department.employees.rowCount > 0}" value="this department has employees"/>
      </ui:repeat>



      The first rowCount is evaluated correctly; for the second rowCount (the one from employees) I get this:

      SEVERE: Error Rendering View[/departments.xhtml]
      java.lang.NumberFormatException: For input string: "rowCount"
      at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
      at java.lang.Integer.parseInt(Integer.java:447)
      at java.lang.Integer.parseInt(Integer.java:497)
      at com.sun.facelets.el.LegacyELContext$LegacyELResolver.getValue(LegacyELContext.java:138)

      If I just simply iterate the employees works ok, but the rowCount doesn't, why? Thanks.

        • 1. Re: rowCount
          kh2ouija

          Ok. so I used #{not empty department.employees} instead and this works. For educational reasons, what was wrong with using rowCount here?

          • 2. Re: rowCount
            kh2ouija

             

            <h:outputText value="You have #{websites.rowCount} websites." rendered="#{not empty websites}"/>


            This exact bit renders to "You have 0 websites." for an empty list, does anyone have any idea why?

            • 3. Re: rowCount
              gavin.king

              rowCount is a property of DataModel. If you have an ordinary collection, it is not the correct way.

              • 4. Re: rowCount

                What would be the correct way here?

                James

                • 5. Re: rowCount
                  gavin.king

                  #{size websites} works, i think

                  • 6. Re: rowCount

                    Im actually trying to put a count column for each row, but not sure exactly how, or real familiar with the inner workings of JSF.

                    in jBPM I have
                    <ui:repeat var="taskInstance" value="#{participantBean.personalTaskInstances}">

                    <h:outputText value="*NEEDCNT*"/>.

                    Where I loop through these instances #{taskInstance.name}

                    James

                    • 7. Re: rowCount
                      gavin.king

                      Oh, for that I don;t know any way other than wrapping it in a DataModel and using #{dataModel.rowIndex}.

                      I've never needed to do this...