• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Detection of changes in values of JSP Elements

 
Anand Srinivas
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65229
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This ia an all-Javascript issue so off to the HTML/Javascript forum it goes.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Anand Srinivas
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot friends
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic