Skip to main content

Posts

Showing posts with the label JSF

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

 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) }