How to display value of List#size() in JSF EL?

后端 未结 1 951
无人及你
无人及你 2020-12-16 11:43

I\'d like to know if there\'s a way to bind the returned value of a method into a JSF component. I\'ll explain myself better. Let\'s say I have a class like this:

         


        
1条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-16 12:00

    If you're running an EL 2.2 capable container (Tomcat 7, Glassfish 3, JBoss AS 6 or newer, all implementing Servlet 3.0), or are using JBoss EL, then you should be able to invoke non-getter methods by EL:

    
    

    An alternative is to use JSTL fn:length():

    
    ...
    
    

    If none of that is possible for you for some reason, then your best bet is to create an EL function yourself

    
    

    or to add an extra getter method to #{myManagedBean} which returns exactly that.

    
    

    See also:

    • Invoke direct methods or methods with arguments / variables / parameters in EL

    0 讨论(0)
提交回复
热议问题