开发者

Change dynamically css class

开发者 https://www.devze.com 2022-12-10 03:53 出处:网络
Imagine that i have the following code: <a:repeat value=\"#{bean.getList()}\" var=\"x\" > <li class=\"la\">

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>
0

精彩评论

暂无评论...
验证码 换一张
取 消