• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Saving the form before navigating to some other page

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using struts framework.

I have page1, page2, etc.
On page1 there is a link to navigate to page2. Also there is a form on page1 that user fills in and submits. If user enters details on this form and clicks on the page2 link without submitting the form I would like to prompt the user whether he wants to save or not. If user says yes, I need to save the form and stay in the same page. If user says no, I need to proceed to next page without saving it. I want to do this action in the web-tier.

Thanks!

 
Sheriff
Posts: 9674
42
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Rohithaksha Kalluraya wrote:If user says yes, I need to save the form


What do you mean by save the form?? You can use a javascript confirm dialog to prompt the users choice of yes or no. This confirm dialog can be shown on the onclick event of the hyperlink. If the user chooses to navigate to the other page, you'll return true from javascript. If user wants to stay at the page, then you'll return false from the javascript, when the onclick event of a hyperlink returns false, the browser doesn't follows the hyperlink...
 
Rohithaksha Kalluraya
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank You for the reply!

Let me rephrase the question. I have a page "page1", that page has a form (where user can enter details, ex., account creation form). I don't want to do a frontend validation using javascript, but would like to use MVC framework that validates and remembers the user input even if the user does not submit that form. Closest example of this I can think of is, gmail that keeps saving the composed emails. Even if user loses connections or forgets to send the email, that email will be saved and can be retrieved from Drafts folder.

Thanks again!
 
Ankit Garg
Sheriff
Posts: 9674
42
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What gmail does is that it keeps making ajax requests at regular time intervals and sends all the form data (the email in case of gmail) to a specific servlet/struts action on the server which saves the values somewhere (in drafts folder in case of gmail). That's what you need to implement too. The exact implementation details will depend on your requirements...
 
Everybody's invited. Except this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic