This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Struts and the fly likes Problem asking for confirmation before excecuting an action Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Problem asking for confirmation before excecuting an action " Watch "Problem asking for confirmation before excecuting an action " New topic
Author

Problem asking for confirmation before excecuting an action

Edgar Rms
Greenhorn

Joined: Jul 28, 2011
Posts: 2
Hi everyone!

I've been around this forum for a while and you people have saved me a lot of times (thanks by the way), but this time I haven't found any answer to my specific problem, so I'm opening this new thread.

The situation is as follows: In my web app I have a "delete" link, which calls an action to do the work, it looks like:



It works like a charm. But I would like to ask before deletion.

My idea is to use jquery jConfirm().

I have this js function:



and my modified struts tag



The result of all this is:

1) on click, appears the confirm dialog.
2) about 1 sec after (before I can even choose an option on the dialog) the browser takes me automatically to "./"

If I go back on my browser, the previous page loads with the confirm dialog, this time it waits for a choose and it does exactly what it has to do.

My problem is, as you can see, that "go without confirm".

I've tried with a simple html tag


In this case it waits, but won't send the appropriate values to the js function since it sends literaly "%{name}" and "%{id}".

PS this is my first "real word job" so I might be asking for a text book situation (if that's the case, please point me to the text book)

Thanks in advance
Shankar Tanikella
Ranch Hand

Joined: Jan 30, 2011
Posts: 329

Hi Edgar,
I am not quite sure about struts2 tags but his is how i can see your problemThis line of code is trying to do 2 things asynchronously.
1. On Click event
2. href event.
removing either of them would work fine. I prefer you remove onclick and retain href. Try the below piece of code and see if it works out.


Have Fun with Java
little,little.. little by little makes a lot..
Edgar Rms
Greenhorn

Joined: Jul 28, 2011
Posts: 2
Works like a charm.

Thanks a lot

"live another day and learn another thing"
 
Don't get me started about those stupid light bulbs.
 
subject: Problem asking for confirmation before excecuting an action
 
Similar Threads
[struts 2] Use Javascript confirm() dialog
Multilanguage confirm dialog?[RESOLVED]
s:href and onclick , dealing with two different actions
Not able to call javascript function from struts tag
passing form parameters such us textfield values using url tag