Requirement: there is a button with text "disable". I want it to be disabled when page opens. When the user clicks on the button, I want my form fields to get enabled and at the same time I want my button value to be change to "enabled".
I have an example of how to change the value of the button, but how do I enable/disable it at the same time?
<h:form>
Please press the Button it.
<h:commandButton id="cb1" value="#{ActionBean.buttonText}"
immediate="true" actionListener="#{ActionBean.processMyAction}" />
</h:form>
My bean class looks like this:
/* Action listener method */
public void processMyAction(ActionEvent event) {
disable = !disable;
System.out.println("disable: " + disable);
if (buttonText.equals("Disable")) {
buttonText = "Enable";
System.out.println("buttonText: " + buttonText);
} else {
buttonText = "Disable";
System.out.println("buttonText: " + buttonText);
}