[英]Using JSTL function in JSF
i want to use the JSTL function contains in JSF2 here's what i tried but the condition always evaluates to false, i think i am missing something: 我想使用JSF2中包含的JSTL函数 ,这是我尝试过的方法,但条件总是评估为false,我认为我缺少了一些东西:
<c:forEach items="#{myBean.toSendCheckBoxes}" var="entry" varStatus="loop">
<input type="checkbox" name="myArray" value="#{entry.value}" />
<c:choose>
<c:when test="#{fn:contains(entry.key,'g')}">
<ice:graphicImage url="/resources/images/image1.bmp" />
<b>#{entry.key}</b>
</c:when>
<c:otherwise>
<ice:graphicImage url="/resources/images/image2.bmp" />
<span>#{entry.key}</span>
</c:otherwise>
</c:choose>
</c:forEach>
if there's another JSF way to accomplish that, would be very nice to mention it, thanks in advance. 如果还有另一种JSF方式可以做到这一点,请提前感谢。
More JSFish way to do it would be 更多的JSFish方法可以做到
<ui:repeat value="#{myBean.toSendCheckBoxes}" var="entry" varStatus="loop">
<input type="checkbox" name="myArray" value="#{entry.value}" />
<ui:fragment rendered="#{fn:contains(entry.key,'g')}">
<ice:graphicImage url="/resources/images/image1.bmp" />
<b>#{entry.key}</b>
</ui:fragment>
<ui:fragment rendered="#{!fn:contains(entry.key,'g')}">
<ice:graphicImage url="/resources/images/image2.bmp" />
<span>#{entry.key}</span>
</ui:fragment>
</ui:repeat>
or even 甚至
<ui:repeat value="#{myBean.toSendCheckBoxes}" var="entry" varStatus="loop">
<input type="checkbox" name="myArray" value="#{entry.value}" />
<ice:graphicImage url="#{fn:contains(entry.key,'g') ? '/resources/images/image1.bmp' : '/resources/images/image2.bmp'}" />
<span class="#{fn:contains(entry.key,'g') ? 'bold-style' : ''}">#{entry.key}</span>
</ui:repeat>
but I would expect your condition to evaluate properly nevertheless. 但我希望您的情况能够得到正确评估。
I use t:dataList
(myfaces tomahawk xmlns:t="http://myfaces.apache.org/tomahawk"
) for looping over elements to have correct identifier generation and rendered
attribute for different displaying of elements in the list. 我使用t:dataList
(myfaces t:dataList
xmlns:t="http://myfaces.apache.org/tomahawk"
)来循环元素,以具有正确的标识符生成和rendered
属性,以用于列表中元素的不同显示。
<t:dataList layout="simple" value="#{myBean.toSendCheckBoxes}" var="entry">
<input type="checkbox" name="myArray" value="#{entry.value}" />
<h:panelGroup rendered="#{fn:contains(entry.key,'g')}">
<ice:graphicImage url="/resources/images/image1.bmp" />
<b>#{entry.key}</b>
</h:panelGroup>
<h:panelGroup rendered="#{not fn:contains(entry.key,'g')}">
<ice:graphicImage url="/resources/images/image2.bmp" />
<span>#{entry.key}</span>
</h:panelGroup>
</t:dataList>
I've had issues with dynamic element rendering (show/hide rows) within ui:repeat
, so I had to use t:dataList
instead. 我在ui:repeat
存在动态元素渲染(显示/隐藏行)的问题,所以我不得不改用t:dataList
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.