在 JSF Primefaces 中使用一个单选框禁用两个控件
disable two controls using one radio box in JSF Primefaces
我必须使用一对单选按钮禁用页面上的两个控件
我有以下代码:
<p:selectOneRadio id="console" binding="#{yesOrNo}" required="true">}">
<f:selectItem itemValue="Yes" itemLabel="UPLOAD CLR" />
<f:selectItem itemValue="No" itemLabel="ORDER NUMBER" />
<p:ajax update="yesdata" />
</p:selectOneRadio>
<p:fileUpload id="yesdata" fileUploadListener="#cBean.handleFileUpload}"
label="Upload NC CLR" mode="advanced" multiple="false"
update="createConfigPanel" auto="true" sizeLimit="100000" allowTypes="/(\.|\/)(xls|xlsx)$/" disabled="#yesOrNo.value != 'Yes'}" />
上面代码的问题是我不能对另一个控件使用相同的 ID。代码续:
<h:panelGrid columns="2" cellpadding="8">
<p:outputLabel for="serviceType" value="Service Type" />
<p:inputText id="serviceType"
value="#{cBean.serviceType}" required="true"></p:inputText>
...
我想在上面的例子中点击UPLOAD CLR时禁用这个输入框。
请推荐
您可以在 update
属性中定义要更新的多个组件。只需添加另一个 ID,例如:
update="id1 id2"
我必须使用一对单选按钮禁用页面上的两个控件 我有以下代码:
<p:selectOneRadio id="console" binding="#{yesOrNo}" required="true">}">
<f:selectItem itemValue="Yes" itemLabel="UPLOAD CLR" />
<f:selectItem itemValue="No" itemLabel="ORDER NUMBER" />
<p:ajax update="yesdata" />
</p:selectOneRadio>
<p:fileUpload id="yesdata" fileUploadListener="#cBean.handleFileUpload}"
label="Upload NC CLR" mode="advanced" multiple="false"
update="createConfigPanel" auto="true" sizeLimit="100000" allowTypes="/(\.|\/)(xls|xlsx)$/" disabled="#yesOrNo.value != 'Yes'}" />
上面代码的问题是我不能对另一个控件使用相同的 ID。代码续:
<h:panelGrid columns="2" cellpadding="8">
<p:outputLabel for="serviceType" value="Service Type" />
<p:inputText id="serviceType"
value="#{cBean.serviceType}" required="true"></p:inputText>
...
我想在上面的例子中点击UPLOAD CLR时禁用这个输入框。
请推荐
您可以在 update
属性中定义要更新的多个组件。只需添加另一个 ID,例如:
update="id1 id2"