如何根据ui:repeat
列表中的特定复选框的值动态禁用inputTextarea
?
<ui:repeat var="eligibilityReason"
value="#{itemDetails.itemSelected.listEligibilityReasons}">
<h:selectBooleanCheckbox id="eligibilityReasonOptId"
value="#{eligibilityReason.selected}"/>
<h:outputText value="#{eligibilityReason.eligiReasonDescr}"/>
</ui:repeat>
<h:inputTextarea id="ineligiReasonOtherId"
value="#{itemDetails.itemSelected.ineligiReasonOther}"
disabled="???" />
背豆:
private String eligiReason;
private String eligiReasonDescr;
private boolean selected;
listEligibilityReasons
得到了一个List<EligibilityReason>
.那么如何仅根据eligiReason='99'
的选定/复选框值动态启用/禁用inputTextarea
呢?
这样的事情应该做。ajax 事件仅针对项目 99 触发,并调用 Java 方法为文本区域设置布尔标志。 这是未经测试的,但可以让您了解需要做什么。
<ui:repeat var="eligibilityReason" value="#{itemDetails.itemSelected.listEligibilityReasons}">
<p:selectBooleanCheckbox id="eligibilityReasonOptId" value="#{eligibilityReason.selected}" itemLabel="#{eligibilityReason.eligiReasonDescr}">
<p:ajax listener="#{view.reason99}" disabled="#{eligibilityReason.eligiReason eq '99'}" update="ineligiReasonOtherId" />
</p:selectBooleanCheckbox>
</ui:repeat>
<h:inputTextarea id="ineligiReasonOtherId"
value="#{itemDetails.itemSelected.ineligiReasonOther}"
disabled="#{view.textAreaDisabled}" />
爪哇岛:
boolean textAreaEnabled = false;
public void reason99(AjaxBehaviorEvent event) {
textAreaEnabled = event.getSource().getValue();
}