【发布时间】:2011-01-11 15:24:37
【问题描述】:
我正在尝试使“h:selectBooleanCheckbox”组件在复选框设置为 true(选中)后使另一个 h:inputbox 被禁用。
我尝试了几个版本,但都没有成功(当我选中该框时,没有任何反应)
版本 1
<f:view>
<h:form id="MyForm">
<h:panelGrid id="OutgoingMailPanel" styleClass="subConfigurationPanel">
<h:panelGrid columns="1">
<h:outputText styleClass="propertyName" value='Password' />
<h:outputText styleClass="properyDescription" value='Password for the incoming mail server' />
<h:inputText id="OutGoingMail" styleClass="propertyInput" value="#{email.currentOutgoingMailPassword[0]}" />
</h:panelGrid>
<h:panelGrid columns="1">
<h:panelGroup>
<h:selectBooleanCheckbox value="#{email.currentUsePasswordSameAsIncoming[0]}"
onclick="document.getElementById('MyForm:OutGoingMail).disable = !this.checked" />
<h:outputText styleClass="propertyName" value='Outgoing Password Same As Incoming.' />
</h:panelGroup>
</h:panelGrid>
</h:panelGrid>
</h:form>
</f:view>
第 2 版
<f:view>
<h:form id="MyForm">
<h:panelGrid id="OutgoingMailPanel" styleClass="subConfigurationPanel">
<h:panelGrid columns="1">
<h:outputText styleClass="propertyName" value='Password' />
<h:outputText styleClass="properyDescription" value='Password for the incoming mail server' />
<h:inputText id="OutGoingMail" styleClass="propertyInput" value="#{email.currentOutgoingMailPassword[0]}"
disabled="#{email.currentUsePasswordSameAsIncoming[0]}"/>
</h:panelGrid>
<h:panelGrid columns="1">
<h:panelGroup>
<h:selectBooleanCheckbox value="#{email.currentUsePasswordSameAsIncoming[0]}" >
<a4j:support event="onclick" rerender="OutGoingMail">
</h:selectBooleanCheckbox>
<h:outputText styleClass="propertyName" value='Outgoing Password Same As Incoming.' />
</h:panelGroup>
</h:panelGrid>
</h:panelGrid>
</h:form>
</f:view>
两个版本都因同样的原因不能工作 - 当我选中该框时没有任何反应。 有任何想法吗? (使用 Jsf1.2、myfaces、richfaces)
谢谢!
【问题讨论】: