Laurie Harper wrote:
Scott Van Wart wrote:
We have a requirement that the user be prompted if any changes have been made on a form, and they try to navigate away. I've divided this up
Firstly, is the requirement to detect changes to the form compared to how it was last rendered, or compared to how it was *originally* rendered? I.e. do you have to be able to detect a difference in form state across multiple requests?
Originally rendered. I need to render the hidden fields because it's a multi-user system, and I have other mechanisms that maintain concurrency--so by passing the fields back and forth as hidden, the process doesn't get disrupted by someone else changing it in the background (I can use my other methods of notifying the user that this has happened).
Even then, all you really need is a Javascript object containing key/value pairs describing each form property's starting value. You shouldn't need to worry about server-side data types, collections, or anything else; just 'form field X has value Y'.

There are a few things I need to worry about by design:
- Child items listed on a page, and their order.
- Multi-select dropdowns.
- Multiple checkboxes (this one actually wasn't as difficult as I thought it was going to be). - Map-based nested beans (someForm.someChild(4).whatever--ahh, a simple key=value? Nope, whatever is a multi-checkbox).

Right now I'm halfway through my implementation of generating a lot of stuff myself. Rather than using beanutils, I just add a @NavPrompt annotation to each private member of my ActionForm that I want to track. I've implemented basic ones (where I can just do document.form.whatever.value != "..."), multi-selects (with a helper method), multi-checkboxes (with a helper method), but I still need to do nested beans and map-based beans.

I decided to do it this way rather than simple key/value pairs to keep the JavaScript as simple as possible. It's also possible that with better knowledge of JavaScript I could reduce the amount of framework I need to write on the server, but writing Java code is far more fun than learning--let alone writing--JavaScript IMHO :).

Thanks,
 Scott


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to