Change dynamically css class
Imagine that i have the following code:
<a:repeat value="#{bean.getList()}" var="x" >
<li class="la">
<span>
<img src="#{bean.getThumbImageUrl(x)}"/>
</span>
</li>
</a:repeat>
I'm receiving a List of elements on bean.getList(). For each element, i'm getting it's image and print it. On the <li>
tag, i'm defining a specific开发者_如何学JAVA class. What i need it's to apply a different class to the last element of bean.getList().
Does anyone knows how to do it?
Thanks
Just found the solution:
<a:repeat value="#{bean.getList()}" var="x" rowKeyVar="row">
<li class="#{row==<numberOfElements>?'lala':''}">
<span>
<img src="#{bean.getThumbImageUrl(x)}"/>
</span>
</li>
</a:repeat>
Thanks for your help Kamil Szot
Maybe you could use :dataList instead of :repeat to conditionally output something (class) for the last element, like in the following googled piece of code?
<t:dataList rowCountVar="rowCount" rowIndexVar="rowIndex">
<h:outputText value="," rendered="#{(rowCount-1)!=rowIndex}">
</t:dataList>
精彩评论