0

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.

1
  • 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'); Commented Jul 23, 2014 at 19:47

1 Answer 1

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
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.