I have a data input form with h:(or p:)inputText components. I also have a save button to save the fields to the backing bean. What I want, actually, what my boss wants, is to disable the save button until some text on the form has been changed, i.e. wait until the form is dirty before allowing the save button to be active. I know how to do it using ajax; what I want to do is have it work in the client so it is entirely independent from the server.
Asked
Active
Viewed 1,252 times
0
-
Depending on the implementation of JSF you use, it should be as simple as using the javascript to select the button, add a disabled class, set the "disabled" property, and whatever else your implementation uses. I use PrimeFaces, so my "disable this button" code looks like this: `$('#tabs\\:disposition\\:submitPAButton > button').addClass('ui-state-disabled').attr('disabled','disabled').attr('aria-disabled','true');` – RevanProdigalKnight Jul 23 '14 at 19:47
1 Answers
0
If its Primefaces command button then you can use components widgetVar to call Client Side API function to Enable/Disable the p:commandButton
from Javascript.
Example:
Facelet code:
<p:commandButton id="primeCmdBtn" widgetVar="primeBtnWidget"/>
Javascript Code:
primeBtnWidget.enable(); //to Enable the button
primeBtnWidget.disable(); //to Disable the button

Kishor Prakash
- 8,011
- 12
- 61
- 92