Using a4j:repeat or ui:repeat inside rich:dataTable doesn't render radio buttons properly

与世无争的帅哥 提交于 2019-12-24 00:30:06

问题


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

How do I resolve this issue?

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

回答1:


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}" />

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()));
}

so that you can end up with

<f:selectItems value="#{answer.selectItems}" />


来源:https://stackoverflow.com/questions/2166934/using-a4jrepeat-or-uirepeat-inside-richdatatable-doesnt-render-radio-buttons

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!