File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Struts Action called twice Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts Action called twice " Watch "Struts Action called twice " New topic

Struts Action called twice

Lavanya Mothilal
Ranch Hand

Joined: Dec 27, 2007
Posts: 30

I am using an image with an <a> tag (like the one below) to submit a form with the help of javascript.

After the form submits using the "deletedetails" method, some times the action is called twice which leads to some undesired results (like trying to delete an already deleted record from a database). As I mentioned, this behaviour is not consistent and at times the action is called only once as desired.

Anyone know the reason behind this ?

Thanks,<br />Lavanya
Arun Christopher

Joined: Nov 18, 2008
Posts: 19

I know this is too late for the reply.

But i feel someone will find this helpful.

move the onclick function to href tag like the code in the image attached

This will work perfectly.


[Thumbnail for script.JPG]

David Newton

Joined: Sep 29, 2008
Posts: 12617

You attached an image of some code rather than just typing it in or cut-and-pasting?!?! Come on.
Of course, this isn't really what you'd want to do, because it would be useless for those with JavaScript turned off, or sites that must maintain accessibility for legal or ethical reasons.

@OP: Asking a JavaScript question without any actual JavaScript is a suboptimal approach.

I also don't see any reason to use an image input there if all you really need is an image.
Darshana Bhandare

Joined: Dec 07, 2009
Posts: 1
your problem here is <input type="image"
make it "<img"
and have fun!!!

Darshana Bhandare
I agree. Here's the link:
subject: Struts Action called twice
It's not a secret anymore!