I am trying to make a commandButton enabled/disabled by using a checkbox. The commandbutton is disabled initially. When user checks the checkbox, the commandbutton turns into enabled. But it does not response when clicked the button.
If I make the commandbutton independent from checkbox, it works fine. But with checkbox, I get the problem that I mentioned above. Please help me
Here are codes.
index.xhtml
<h:form>
<h:selectBooleanCheckbox value="#{formSettings.licenseAccepted}" id="cb">
<f:ajax event="click" render="suB cb"/>
</h:selectBooleanCheckbox>
<h:outputText value="#{formSettings.msg}"/><br/>
<h:commandButton id="suB" disabled="false" value="Save" action="loginSuccessfull"/>
</h:form>
FormSettings.java
package classes;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
@ManagedBean
@RequestScoped
public class FormSettings
{
private boolean licenseAccepted = false;
private String msg = "Accept License";
public FormSettings(){};
public boolean isLicenseAccepted(){return this.licenseAccepted;};
public void setLicenseAccepted(boolean licenseAccepted){this.licenseAccepted = licenseAccepted;};
public String getMsg(){return this.msg;};
public void setMsg(String msg){this.msg = msg;};
}
faces-config.xml
<?xml version="1.0" encoding="UTF-8"?>
<faces-config
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
version="2.0">
<navigation-rule>
<from-view-id>/index.xhtml</from-view-id>
<navigation-case>
<from-outcome>loginSuccessfull</from-outcome>
<to-view-id>/login.xhtml</to-view-id>
</navigation-case>
</navigation-rule>
</faces-config>