You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Stanley, Eric" <Er...@qwest.com> on 2008/05/27 19:08:37 UTC

Javascript in S2

All,
    What are my options if I want to use a confirm when a user clicks a
S2 anchor? Its an anchor that will remove something, so I want the user
to confirm that before the database gets touched. Currently the confirm
is not there, and when you click the anchor, the item is removed. No
bueno. Time to do it right.
 
E. Ryan Stanley
Phone: 720.578.3703
Pager: 801.482.0172
<ma...@qwest.com>  
 


This communication is the property of Qwest and may contain confidential or
privileged information. Unauthorized use of this communication is strictly 
prohibited and may be unlawful.  If you have received this communication 
in error, please immediately notify the sender by reply e-mail and destroy 
all copies of the communication and any attachments.

Re: Javascript in S2

Posted by Roger Varley <ro...@googlemail.com>.
On Tuesday 27 May 2008 20:58:53 Stanley, Eric wrote:
> Musachy / Laurie,
> 	Thanks for setting me straight. Working perfectly. Laurie, at a
> high level, how would you use the backend to do this? I'd like to go
> this way, but ive never done it before. Thanks for any input :)
>

I suppose that, simplistically, the logic flow would go something like

1) User clicks "Delete" which calls the delete() method on your action.
2) Your action does nothing except forward to confirmDelete.jsp
3) If the user clicks confirm then call a confirmedDelete() method in your 
action that actually performs the deletion.

You could harden this by storing a flag in the session so that you can ensure 
that confirmedDelete() cannot be called without going through delete() first.

If you needed confirmedDelete() functionality throughout your application, I 
would look into the possibility of creating a custom interceptor to provide 
this functionality.

However, I have no idea how to make your confirmDelete.jsp appear as a pop-up 
window over the existing display. If anyone knows how to do this I'd be 
eternally grateful

Regards


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: Javascript in S2

Posted by "Stanley, Eric" <Er...@qwest.com>.
Musachy / Laurie,
	Thanks for setting me straight. Working perfectly. Laurie, at a
high level, how would you use the backend to do this? I'd like to go
this way, but ive never done it before. Thanks for any input :)

-Ryan 

-----Original Message-----
From: Musachy Barroso [mailto:musachy@gmail.com] 
Sent: Tuesday, May 27, 2008 11:51 AM
To: Struts Users Mailing List
Subject: Re: Javascript in S2

You have to return "false" from that function in order to cancel the
submit. It is a javascript thing, as far as Struts is concerned,
anything you put into "onclick" will be passed outputted to the onclick
event in the generated html.

musachy

On Tue, May 27, 2008 at 1:46 PM, Stanley, Eric
<Er...@qwest.com> wrote:
> Laurie,
>        Thanks for the quick reply, but I have tried that. It does 
> display the confirm window, but the users approval/denial has no
effect.
> The record gets removed regardless. What am I missing? Im sure it's a 
> simple thing :)
>
> -Ryan
>
> -----Original Message-----
> From: news [mailto:news@ger.gmane.org] On Behalf Of Laurie Harper
> Sent: Tuesday, May 27, 2008 11:21 AM
> To: user@struts.apache.org
> Subject: Re: Javascript in S2
>
> Stanley, Eric wrote:
>> All,
>>     What are my options if I want to use a confirm when a user clicks

>> a
>> S2 anchor? Its an anchor that will remove something, so I want the 
>> user to confirm that before the database gets touched. Currently the 
>> confirm is not there, and when you click the anchor, the item is 
>> removed. No bueno. Time to do it right.
>
> Your options are the same as in any other HTML + Javascript context. 
> At simplest, use an onclick="javascript:confirm('prompt')" type
construct.
> You should really consider putting the guard logic server-side, 
> though, so it isn't bypassed if Javascript is disabled in the user's 
> browser (depending how critical the delete operation is).
>
> L.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
> This communication is the property of Qwest and may contain 
> confidential or privileged information. Unauthorized use of this 
> communication is strictly prohibited and may be unlawful.  If you have

> received this communication in error, please immediately notify the 
> sender by reply e-mail and destroy all copies of the communication and
any attachments.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>



--
"Hey you! Would you help me to carry the stone?" Pink Floyd

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Javascript in S2

Posted by Musachy Barroso <mu...@gmail.com>.
You have to return "false" from that function in order to cancel the
submit. It is a javascript thing, as far as Struts is concerned,
anything you put into "onclick" will be passed outputted to the
onclick event in the generated html.

musachy

On Tue, May 27, 2008 at 1:46 PM, Stanley, Eric <Er...@qwest.com> wrote:
> Laurie,
>        Thanks for the quick reply, but I have tried that. It does
> display the confirm window, but the users approval/denial has no effect.
> The record gets removed regardless. What am I missing? Im sure it's a
> simple thing :)
>
> -Ryan
>
> -----Original Message-----
> From: news [mailto:news@ger.gmane.org] On Behalf Of Laurie Harper
> Sent: Tuesday, May 27, 2008 11:21 AM
> To: user@struts.apache.org
> Subject: Re: Javascript in S2
>
> Stanley, Eric wrote:
>> All,
>>     What are my options if I want to use a confirm when a user clicks
>> a
>> S2 anchor? Its an anchor that will remove something, so I want the
>> user to confirm that before the database gets touched. Currently the
>> confirm is not there, and when you click the anchor, the item is
>> removed. No bueno. Time to do it right.
>
> Your options are the same as in any other HTML + Javascript context. At
> simplest, use an onclick="javascript:confirm('prompt')" type construct.
> You should really consider putting the guard logic server-side, though,
> so it isn't bypassed if Javascript is disabled in the user's browser
> (depending how critical the delete operation is).
>
> L.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
> This communication is the property of Qwest and may contain confidential or
> privileged information. Unauthorized use of this communication is strictly
> prohibited and may be unlawful.  If you have received this communication
> in error, please immediately notify the sender by reply e-mail and destroy
> all copies of the communication and any attachments.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>



-- 
"Hey you! Would you help me to carry the stone?" Pink Floyd

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: Javascript in S2

Posted by "Stanley, Eric" <Er...@qwest.com>.
Laurie,
	Thanks for the quick reply, but I have tried that. It does
display the confirm window, but the users approval/denial has no effect.
The record gets removed regardless. What am I missing? Im sure it's a
simple thing :)

-Ryan 

-----Original Message-----
From: news [mailto:news@ger.gmane.org] On Behalf Of Laurie Harper
Sent: Tuesday, May 27, 2008 11:21 AM
To: user@struts.apache.org
Subject: Re: Javascript in S2

Stanley, Eric wrote:
> All,
>     What are my options if I want to use a confirm when a user clicks 
> a
> S2 anchor? Its an anchor that will remove something, so I want the 
> user to confirm that before the database gets touched. Currently the 
> confirm is not there, and when you click the anchor, the item is 
> removed. No bueno. Time to do it right.

Your options are the same as in any other HTML + Javascript context. At
simplest, use an onclick="javascript:confirm('prompt')" type construct. 
You should really consider putting the guard logic server-side, though,
so it isn't bypassed if Javascript is disabled in the user's browser
(depending how critical the delete operation is).

L.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


This communication is the property of Qwest and may contain confidential or
privileged information. Unauthorized use of this communication is strictly 
prohibited and may be unlawful.  If you have received this communication 
in error, please immediately notify the sender by reply e-mail and destroy 
all copies of the communication and any attachments.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Javascript in S2

Posted by Laurie Harper <la...@holoweb.net>.
Stanley, Eric wrote:
> All,
>     What are my options if I want to use a confirm when a user clicks a
> S2 anchor? Its an anchor that will remove something, so I want the user
> to confirm that before the database gets touched. Currently the confirm
> is not there, and when you click the anchor, the item is removed. No
> bueno. Time to do it right.

Your options are the same as in any other HTML + Javascript context. At 
simplest, use an onclick="javascript:confirm('prompt')" type construct. 
You should really consider putting the guard logic server-side, though, 
so it isn't bypassed if Javascript is disabled in the user's browser 
(depending how critical the delete operation is).

L.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org