【问题标题】:JSF custsom DIV class to be displayed要显示的 JSF 自定义 DIV 类
【发布时间】:2014-11-15 21:02:37
【问题描述】:

我有这个 html 列表代码:

<div class="destination-places-grid">
  Item 1
</div>

<div class="destination-places-grids">
  Item 2
</div>

<div class="destination-places-grids last-d-grid">
  Item 3
</div>

<div class="destination-places-grid">
  Item 4
</div>

<div class="destination-places-grids">
  Item 5
</div>

<div class="destination-places-grids last-d-grid">
  Item 6
</div>

如您所见,每 3 个项目,div 的类需要更改,我想知道在 JSF 2 中将其放入列表的更优雅的方法,我尝试使用 p:dataList 并使用呈现的属性不接受 ," 或',因此通过编写它们的 html 等价物,如

 <p:dataList value="#{destinationController.destinationList}" rowIndexVar="row"
                var="destination" type="ordered"  >


 <h:outputText value="#{((row+1) mod 3) == 0 ? &lt;div class=&quot;destination-places-grid last-d-grid&quot;&gt; : &lt;div class=&quot;destination-places-grid&quot;#&apos;;&quot;&gt;'}"/>

<p:dataList >

这里的正确方法应该是什么?

【问题讨论】:

    标签: jsf primefaces el rowcount


    【解决方案1】:

    希望这是你想要的:

    <p:dataList ............
                rowIndexVar="row" 
                itemStyleClass="#{((row+1) mod 3) eq 0 ? 'destination-places-grids last-d-grid', 'destination-places-grids' }" />
    
        ... content
    
    </p:dataList/>
    

    【讨论】:

    • 这对我来说几乎是完美的,唯一的问题是它呈现了一个
    • 等等......我需要一个
  • 没关系,我所要做的就是更改相应的 CSS,这解决了我的问题。 :) 谢谢!
  • 猜你喜欢
    相关资源
    最近更新 更多
    热门标签