在rich:dataTable中使用a4j:repeat或ui:repeat无法正确呈现单选按钮 [英] Using a4j:repeat or ui:repeat inside rich:dataTable doesn't render radio buttons properly
问题描述
使用<c:forEach>
时,项目值未正确替换.如果我在<a4j:repeat>
或<ui:repeat>
而不是<c:forEach>
,则单选按钮无法正确呈现.我还在 http://community.jboss.org/wiki/Cantusea4jrepeattoiteratethemenuItemstabsetc 中找到了原因
While using <c:forEach>
the items values is not substituted properly. If i use <a4j:repeat>
or <ui:repeat>
instead of <c:forEach>
inside a <rich:dataTable
>, radio button is not rendering properly. I also found reason for this in http://community.jboss.org/wiki/Cantusea4jrepeattoiteratethemenuItemstabsetc
如何解决此问题?
<f:selectItems>
在内部工作,但我想将选择类型发送到服务器
<f:selectItems>
is working inside but i want to send a choice type to server
<rich:dataTable var="answer" value="#{answers}">
<rich:column>
<f:selectOneRadio value="#{response.value}">
<c:forEach items="#{answer.choices}" var="choice">
<f:selectItem itemLabel="#{choice.value}" itemValue="#{choice.type}"/>
</c:forEach>
</f:selectOneRadio>
</rich:column>
</rich:dataTable>
推荐答案
如果您已经在使用JSF 2.x,则可以使用以下结构:
If you're already on JSF 2.x, then you can just use the following construct:
<f:selectItems value="#{answer.choices}" var="choice" itemValue="#{choice.type}" itemLabel="#{choice.value}" />
如果您仍在使用JSF 1.x,那么最好将f:selectItems
与answer
bean的构造函数中的以下逻辑结合使用以预填充它:
If you're still on JSF 1.x, then best is to use f:selectItems
in combination with the following logic in the constructor of answer
bean to prepopulate it:
this.selectItems = new ArrayList<SelectItem>();
for (Choice choice : this.choices) {
selectItems.add(new SelectItem(choice.getType(), choice.getValue()));
}
这样您就可以结束
<f:selectItems value="#{answer.selectItems}" />
这篇关于在rich:dataTable中使用a4j:repeat或ui:repeat无法正确呈现单选按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!