jsf - commandButton which is enabled by f:ajax does not invoke action when form is submitted -


I am trying to enable / disable the command button using a checkbox. The command button is enabled when the command button is initially disabled when the checkbox checks. But when clicking on the button it does not respond.

If I make CommandBanton independent from the checkbox, it works fine. But with the checkbox, I have the problem I described above. Please help me

Here are the codes.

index.xhtml

  & lt; H: form & gt; & Lt; H: selectBooleanCheckbox value = "# {formSettings.licenseAccepted}" id = "cb" & gt; & Lt; F: ajax event = "click" render = "sub cb" / & gt; & Lt; / H: selectBooleanCheckbox & gt; & Lt; H: output text value = "# {formSettings.msg}" / & gt; & Lt; Br / & gt; & Lt; H: CommandButton ID = "Subby" disabled = "False" value = "Save" action = "LoginFile /" & Lt; / H: form & gt;   

FormSettings.java package classes; Import javax.faces.bean.ManagedBean; Import javax.faces.bean.RequestScoped; @ Managed bean @ request: public class formatting {private boolean license accepted = incorrect; Private string msg = "Accept license"; Public Form Settings () {}; Public Boolean is licensed () (This refund. Public Zero set license acceptance (Boolian license has been accepted) {this.licenseAccepted = License Approved;}; Public string getMsg () {return.msg;}; public zero set message (String msg) {this.msg = msg;};}

face-config.xml

  & lt ;? xml version = "1.0" Encoding = "UTF-8"? & Gt; & lt; faces-config xmlns = "http://java.sun.com/xml/ns/javaee" xmlns: xsi = "http://www.w3.org / 2001 / XMLSchema-instance "XSI: Schema Location =" http://www.java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd " Version = "2.0" & gt; navigation rule & lt; view-id & gt; /index.xhtml< / through-view-id> & lt; navigation-case & gt; & Lt; to-results & gt /; to-result & quot; loginSuccessfull & lt; & lt; to view view id; gt; /login.xhtml< / to view-id & gt; & navigation; / navigation -case & gt; & lt; / navigation rules & lt; / face-config & gt;    

Bean should be kept in the field of view to work.

  @ManagedBean @ViewScoped public class FormSettings {}   

Enabling buttons by calculating the ajax as an HTTP request, then form with button Depositing is counted as another HTTP request. Since your bean is requested, it is made fresh on every HTTP request and is preserved until the end of the request. As the boolean property is for default liar , the button is effectively disabled when JSF is about submitting a form on the second request.

See also:


Comments