3

I want to use a datalist

<rich:dataList value="#{bean.itemsOnLevel}" var="item">
   <h:outputText value="#{item.value}" />
</rich:dataList>

but my getter needs a parameter

public List getItemsOnLevel(int level);

how can I pass the level?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
wutzebaer
  • 14,365
  • 19
  • 99
  • 170

1 Answers1

6

If you're already targeting a Servlet 3.0 compatible container (Tomcat 7, Glassfish 3, JBoss 6, etc) with a Servlet 3.0 compatible web.xml in your webapp, then you can make use of the new EL 2.2 feature of invoking methods with arguments:

<rich:dataList value="#{bean.getItemsOnLevel(1)}" var="item">
   <h:outputText value="#{item.value}" />
</rich:dataList>

If you're however targeting an older Servlet 2.5 compatible container (Tomcat 6, Glassfish 2, JBoss 4/5, etc), then your best bet is to install JBoss EL to achieve the same. See also this answer for details: Invoke direct methods or methods with arguments / variables / parameters in EL

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555