0

I'm using primefaces and jstl to loop a datatable.I have a List in backing bean for the columns.

private List<String> visableCols;
public initCols(){
    visableCols.add("andOr");
    visableCols.add("operator");
    ......
}
// getter & setter

In the xhtml page.

<p:comlumns var="col" value="#{theBean.visableCols}" >
<c:if test="#{col == 'andOr'}">
    <!-- do sth here -->
</c:if>
</p:comumns>

but I found the c:if always false.I tried to print out the #{col} and compare w/ 'andOr',they are the same value.

machcm.sz
  • 127
  • 2
  • 3
  • 11
  • 2
    Don't mix JSTL tags (like ``) with JSF tags. What is the end result that you're trying to achieve? – Matt Ball Nov 08 '11 at 03:27
  • possible duplicate of [JSTL c:if inside a JSF h:dataTable](http://stackoverflow.com/questions/3442380/jstl-cif-inside-a-jsf-hdatatable) – BalusC Nov 08 '11 at 03:30
  • i tried to use instead,but still not works. – machcm.sz Nov 08 '11 at 03:32
  • Hi,Matt.I'm trying to achieve a datatable, which include some deferent cols. e.g when the column equles 'andOr', there will be a selectOneMenu. – machcm.sz Nov 08 '11 at 03:37
  • @machcm.sz: perhaps try to avoid jstl, and make use of to dynamically render or not render some sections ? – Bertie Nov 08 '11 at 03:45
  • @Albert Kam: thx, i use a someCheck() function in the backing bean for the same logic,it works. like this: – machcm.sz Nov 08 '11 at 03:58

1 Answers1

0

If you are using PrimeFaces and you want to dynamically add and remove columns, PrimeFaces provides a specific way of doing that. You don't need any JSTL tags. For a good example of how to do it just look at their showcase example. It is pretty involved but fairly clean.

Note: you use the p:columns tag instead of p:column.

AlanObject
  • 9,613
  • 19
  • 86
  • 142