0

我有一个 jsf,我想在其中显示复选框列表。如果我在下面的示例中创建它,则复选框将正确呈现。

<p:outputPanel layout="block" rendered="#{scheduleConfigBean.selectedMonthType == 1}" style="width: 400px; margin-top: 45px">
  <ui:repeat var="monthDay" value="#{scheduleConfigBean.monthDays}">
    <p:selectBooleanCheckbox value="#{monthDay.checked}" />
    <h:outputText value="#{monthDay.name}" />
  </ui:repeat>
</p:outputPanel>

但是当我向每个复选框添加一个 ajax 事件侦听器时,面板不再呈现。我的问题是什么?

<p:outputPanel layout="block" rendered="#{scheduleConfigBean.selectedMonthType == 1}" style="width: 400px; margin-top: 45px">
  <ui:repeat var="monthDay" value="#{scheduleConfigBean.monthDays}">
    <p:selectBooleanCheckbox value="#{monthDay.checked}">
      <p:ajax listener="#{scheduleConfigBean.updateMonthlyButtonState}" update="saveBtn" />
    </p:selectBooleanCheckbox>
    <h:outputText value="#{monthDay.name}" />
  </ui:repeat>
</p:outputPanel>
4

1 回答 1

0

感谢达卡,他的回答给了我解决方案。

<p:outputPanel layout="block" rendered="#{scheduleCreate.selectedMonthType == 1}" style="width: 500px; margin-top: 45px">
  <c:forEach items="#{scheduleCreate.monthDays}" var="monthDay" varStatus="status">
    <p:selectBooleanCheckbox value="#{monthDay.checked}" style="margin-left: 8px">
      <p:ajax listener="#{scheduleCreate.updateButton}" update="saveBtn" />
    </p:selectBooleanCheckbox>
  </c:forEach>
</p:outputPanel>
于 2013-01-25T11:23:33.370 回答