我正在尝试创建一个“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)
谢谢!
答案 0 :(得分:1)
在您的版本1中修改代码为
document.getElementById('MyForm:OutGoingMail').disabled = this.checked
答案 1 :(得分:0)
在版本2中,rerender应为reRender