Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <h:selecBooleanCheckbox id="box" value="#{mybean.selecteditem.booleanvalue}"......>
- <f:ajax execute="box" render="but" event="change" />
- </h:selectBooleanCheckbox>
- <h:commandButton id="but" action="someAction" value="someValue" disabled="#{!mybean.selecteditem.booleanvalue}" />
- <p:ajax event="change" process="box" update="but"/>
- <f:ajax ......render="id1 id2 id3" />
- public class TestBean {
- private boolean chkBoxChecked;
- public boolean isChkBoxChecked() {
- return chkBoxChecked;
- }
- public boolean isBtnDisabled() {
- return !this.chkBoxChecked;
- }
- public void setChkBoxChecked(boolean chkBoxChecked) {
- this.chkBoxChecked = chkBoxChecked;
- }
- }
- <ui:composition xmlns="http://www.w3.org/1999/xhtml"
- xmlns:ui="http://java.sun.com/jsf/facelets"
- xmlns:f="http://java.sun.com/jsf/core"
- xmlns:h="http://java.sun.com/jsf/html"
- xmlns:a4j="http://richfaces.org/a4j"
- xmlns:rich="http://richfaces.org/rich"
- template="/WEB-INF/template/default.xhtml">
- <ui:define name="content">
- <h:form id="frmTest">
- <h:selectBooleanCheckbox id="chkBoolean" value="#{testBean.chkBoxChecked}">
- <a4j:support event="onclick" ajaxSingle="true" reRender="btnSubmit"/>
- </h:selectBooleanCheckbox>
- <h:commandButton id="btnSubmit" value="Submit" disabled="#{testBean.btnDisabled}"/>
- </h:form>
- </ui:define>
- </ui:composition>
- <ui:composition xmlns="http://www.w3.org/1999/xhtml"
- xmlns:ui="http://java.sun.com/jsf/facelets"
- xmlns:f="http://java.sun.com/jsf/core"
- xmlns:h="http://java.sun.com/jsf/html"
- xmlns:a4j="http://richfaces.org/a4j"
- xmlns:rich="http://richfaces.org/rich"
- template="/WEB-INF/template/default.xhtml">
- <ui:define name="head">
- <script type="text/javascript">
- window.onload = function() {
- btnSubmit = document.getElementById('btnSubmit');
- btnSubmit.disabled = #{testBean.btnDisabled};
- }
- </script>
- </ui:define>
- <ui:define name="content">
- <h:form id="frmTest" prependId="false">
- <h:selectBooleanCheckbox id="chkBoolean"
- onclick="btnSubmit.disabled = !this.checked;"
- value="#{testBean.chkBoxChecked}"/>
- <h:commandButton id="btnSubmit" value="Submit"/>
- </h:form>
- </ui:define>
- </ui:composition>
- <h:form id="myForm">
- <h:selectBooleanCheckbox id="check" onclick="document.getElementById('myForm:myButton').disable = !this.checked"/>
- <h:commandButton id="myButton" .../>
- </h:form>
- onclick="document.getElementById('myForm:myButton').disable = !document.getElementById('myForm:check').checked"
- <script type="text/javascript">
- function checkClick(check) { document.getElementById('myForm:myButton').disable = check.checked; }
- </script>
- (...)
- <h:selectBooleanCheckbox id="check" onclick="checkClick(this)"/>
- (...)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement