wood burning stoves*
The moose likes HTML, CSS and JavaScript and the fly likes Detection of changes in values of JSP Elements Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Detection of changes in values of JSP Elements" Watch "Detection of changes in values of JSP Elements" New topic
Author

Detection of changes in values of JSP Elements

Anand Srinivas
Greenhorn

Joined: Dec 30, 2003
Posts: 8
Hi,
I am working on a J2EE Project with JSP, EJB and Servlets. I have a requirement which requires me to throw a warning message when a user changes some values in a screen and tries to go out of the screen without saving it. There is a catch here. I have implemented the left menu bar in a separate JSP and have included it in every other screens. So if the user modifies any of the screen values and then clicks the left menu bar, how will I be able to track the changes made in the screen values?
If any of you have any suggestions, please help me out.
Thank you in advance.

Anand Srinivas
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Create a 'has_changed' javascript variable in the parent frame.
In every form field, set the 'has_changed' var to true from the onchange event.

Have your nav bar buttons check 'has_changed' and invoke a confirm dialog from the onclick event of the menu buttons if it's true.
[ July 28, 2005: Message edited by: Ben Souther ]

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60773
    
  65

This ia an all-Javascript issue so off to the HTML/Javascript forum it goes.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41085
    
  43
You could also use the onBeforeUnload handler of the page body (might be named slightly differently), which will be invoked before a page gets replaced. From inside it you can prevent a new page from being loaded if necessary. But you'd still need to keep track of altered fields, as suggested above.


Ping & DNS - my free Android networking tools app
Anand Srinivas
Greenhorn

Joined: Dec 30, 2003
Posts: 8
Thanks a lot friends
 
jQuery in Action, 2nd edition
 
subject: Detection of changes in values of JSP Elements
 
Similar Threads
html:mutibox and validation Error
JMenuBar problem in MAC
Problem with JToolBar
How to put menu item in Title bar
Tiles: how to refresh just one tile?