I use rich:modalPanel for editing, so user can't click any links until he/she press "Save" or "Cancel" button placed on modal panel. If user clicks "Cancel" you can check if some fields have been changed and show confirmation.
2) The other way is just track "onchange" event and show confirmation on "Cancel" if "onchange" has been called at least once.
After I posted my query here on Richfaces forum I did google to see if there is available library and I found what you suggested http://github.com/acvwilson/dirty_form. In fact this was only one available and just like Richfaces, it uses JQuery. It was easy and good enough but I had to customize it h:commandLinks.
Getting this library working for normal hrefs was very very easy and covinient but I faced issues with h:commandLink as JSF uses onclick method to actually fire the event rather then href. When user clicks on the h:commandlink, click event is first processed by onclick funtion from JSF and then by the event Listerner created by this library. So no matter what you do in the library specific method you will not be able to stop the page from submission
What that means is if you change anythig on the page and click on h:commandLink , library will open a confirmation box with 2 button Ok and cancel.
Even if you click cancel button page will get submitted. This is more of a issues between this library and JSF rather then Libary and Richfaces. After spending like 2 days I got this working for my application which is using Richfaces 3.3.1. Other then this issue, this looks like a very solution.
I am sure there are lots of applications which will need this feature or won't mind it if Richfaces provided as a part of main JARS and building a standad solution with this library as base would be very easy for us. I have attached here the modified JS file, my layout page and actual page where this is used. This surely can be a boosting point for us as Richfaces family in the market.
Please feel free to contacts me if you need any further input on this topic.
New Folder (2).zip 6.8 K