I have a checkbox and a button on my JSF page. I want the button
What is the JSF way of doing this with no javascript and no listener method on my java class
This is plain impossible. I gather that you actually meant, "no manually written JavaScript" (and thus you accept JSF-generated JavaScript as used by
In that case, this should do:
That's all. No additional JS code nor JSF bean properties or listener methods needed. Just a submit() action method.
The binding attribute will in this example put the UIComponent reference of checkbox. The EL expression #{checkbox.value} returns the value attribute of the component which represents in case of an UISelectBoolean component already a boolean, ready for use in command component's disabled attribute.
Note: if you're facing an incorrect EL error at the line disabled="#{not checkbox.value}" in an older Eclipse version, then you'd need to configure it as follows: Window > Preferences > Web > JavaServer Faces Tools > Validation > Type Coercion Problems > Unary operation boolean coercion problems set it to Warning or Ignore instead of Error. This is not necessary anymore since Eclipse Mars.