Quantcast
Channel: Techie Shah
Viewing all articles
Browse latest Browse all 25

How to get the length of a Collection in the JSF expression language?

$
0
0

 Problem


How to get the length of a Collection in the JSF expression language?

Solution

There are two ways to get the length of a Collection i.e. List, Set, etc in the JSF expression language

a) Define a method in the Bean

In your bean declare a method to return the length of a collection

@Named("MyBean ")
@SessionScoped
public class MyBean {
    private List list;
    .
    .
    .
    public int getCollectionLength() {
      return list.size();
    }
}

b) Using Facelets,the length function

#{ fn:length(MyBean.list) }




Viewing all articles
Browse latest Browse all 25

Trending Articles