What is the syntax for calling list.size() in a JSF 2.0 Facelets template (eg, using an h:outputText element)?
+1
A:
It's not a problem with JSF 2.0 exactly. The JSF spec still requires a class that conforms to the bean spec. The collection classes don't do that with the .size()
method. It would still have to be .getSize()
.
Given the need for a "standard" way to access the class values, we're not getting around that in JSF any time soon. Somebody needs to fix the collection classes.
Jim Barrows
2009-08-27 18:04:05
IC... I was hoping that they had reworked the expression syntax to allow method calls. It could be abused, but it would easily work around cases like this. :) I still don't understand why the collection class designer chose to do things this way.
jsight
2009-08-28 02:41:47
+1
A:
How about this:
<h:outputText value="#{fn:length(someBean.someList)}" />
You'll need to reference the functions
taglib in your JSF page (URI: http://java.sun.com/jsp/jstl/functions
).
harto
2009-09-04 04:49:05
That wouldn't work with standard el. There are el extensions though (such as jboss el) that allow this notation.
Joeri Hendrickx
2010-08-04 14:10:10