Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Prevent double form submit

 
Andreas Daab
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an action prepareEditComment that opens a form and an action editComment that saves something in the database, prepareEditComment is executed via GET, editComment via POST.
With every single click prepareEditComment is executed three times and editComment twice!
saveToken(request) in prepareEditComment and isTokenValid(request) doesn't work for me, because isTokenValid always returns false.

I use struts 1.2.4 on Tomcat 5.0.28.

The following should work, but it doesn't:

public ActionForward prepareEditComment(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
System.out.println("prepareEditComment");
saveToken(request);
return mapping.findForward("prepareEditComment.success");
}

public ActionForward editComment(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
System.out.println("editComment");
if (isTokenValid(request)) {
doSomething();
} else {
resetToken(request);
}
}

Any ideas?
 
Andreas Daab
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not the second call off editComment is the problem, but the first. At the first call the form contains no values. Don't know which of the three prepareEditComment calls ist the correct one.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic