Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to prevent new record creation on page reload?

 
Tina Desai
Ranch Hand
Posts: 365
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Friends,
We have the following:

Scenario:
1. We come to a page by creating a record in the db.
2. The user can enter data and save it multiple times.

Issue:
But if user clicks on reload before step 2, the alert box comes to confirm. On ckick of ok, a new record gets inserted.
A. Can we have some workaround that gets the data but does not insert one more record?
B. Can the refresh be disabled? I have not seen it disabled in the web-apps I browsed so far.

Regards,
 
Timothy Sam
Ranch Hand
Posts: 751
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Perhaps you are using model 1 principle?

Create a hidden input type

<input type="hidden" name="saved" value="<%request.getParameter("saved")%>">

on submit, check if the parameter has already been set, if not set it to something



Bear would probably hate me by giving this answer but if it will help you(and I hope it will) I guess I'm ok with that...

Do yourself a favor and learn Model 2
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Redirect After Post:
http://faq.javaranch.com/view?DoubleSubmitProblem
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do yourself a favor and learn Model 2

Your solution with the hidden param smells like Model 1
[ September 07, 2006: Message edited by: Satou kurinosuke ]
 
Chetan Parekh
Ranch Hand
Posts: 3640
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check DoubleSubmitProblem section in FAQs Section of this forum.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Chetan, you should check it too ;) (joking about same post)
 
Chetan Parekh
Ranch Hand
Posts: 3640
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Satou kurinosuke:
Chetan, you should check it too ;) (joking about same post)


Hey Satou kurinosuke sorry, I just missed that thing
 
Timothy Sam
Ranch Hand
Posts: 751
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was thinking that he might be using model 1 so I decided to give him a solution that fits with it.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hehe, ok
 
Richard Green
Ranch Hand
Posts: 536
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Timothy Sam:
I was thinking that he might be using model 1 so I decided to give him a solution that fits with it.

he? or she?
friday evening here - so please excuse some unrelated posts
 
Tina Desai
Ranch Hand
Posts: 365
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Its SHE!

Timothy, I know model 2! Working on some code not written by us

I have one more issue.. Not going to the confirmation page as such..

Left nav link inserts the record.
And immediately displays it for editing..

I have successfully used a token at a place where the confirmation page is displayed on 'submit' click. But here there is no intermediate such button.
Do we even have a chance to get around this problem in this organization/control flow?

Regards,
Leena
[ September 14, 2006: Message edited by: Tina Desai ]
 
Tina Desai
Ranch Hand
Posts: 365
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anyone?
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you post the relavent part of your code?
Or,, describe step by step what your program is doing so we can make a suggestion.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic