Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Action executed two times

 
Mnau Lubi
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all!

I am having a strange problem. When I click a link in my webpage the action attached to that click is called twice instead of just once... Then, when the action is finished for the 2nd time, it goes where the action forward says. The action works perfectly but it does it two times which is a big problem since the action consist of writing in a database (it writes the same two times ). Anyone knows what could be happening?

Thanks
 
vijay jamadade
Ranch Hand
Posts: 243
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please send the code. Have you used html:submit and also submitting the form through javascript.
 
Rajkamal Pillai
Ranch Hand
Posts: 445
1
Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

On a project one of my team mates faced something of the same sort. Each form had a simple button which would invoke a javascript function call and the function would submit the form based on the status of the form validation. Later this button was changed to a submit button and the same situation arose. Debugging revealed that the form was getting submitted twice. Once with the html submit button. And the next time with the javascript form.submit() call.

I felt it was worth a metion as you could probably have a similar situation. For any more thoughts you ought to post more detail...

Cheers,
Raj.
 
Mnau Lubi
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


When I click in Join, the action /join is called two times
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
http://struts.apache.org/1.2.x/userGuide/struts-html.html#button

If you're not inside a form, don't use Struts 1 form tags.

May not solve the problem, but it's still incorrect.
 
Mnau Lubi
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David Newton wrote:http://struts.apache.org/1.2.x/userGuide/struts-html.html#button

If you're not inside a form, don't use Struts 1 form tags.

May not solve the problem, but it's still incorrect.


Yes that was the problem. However I liked how it looked like when it was with buttons, is it any alternative you can suggest to me?

Thanks
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just use an HTML button w/o the Struts tag?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic