Re: SubmitLink with confirmation dialog

2011-05-01 Thread Pedro Santos
Hi, SubmitLink already write some JavaScript in the onclick handler, so you
need to prepend the confirmation JavaScript in order to maintain the default
behavior. e.g.

submitLink.add(new Behavior() {
onComponentTag() {
tag.put("onclick", "if(!confirm('c')) return false;" +
tag.getAttribute("onclick"));
}
});

In Wicket 1.5 RC4 you can also use the AttributeAppender to prepend the
confirmation JavaScript.

On Sun, May 1, 2011 at 4:03 PM, scorpio2002  wrote:

> Dear Martin,
> thank you for answering. I tried something like this:
>
> --
> SubmitLink link = new SubmitLink("link") {
>public void onSubmit() { /* my stuff */}
> }
>
> link.add(new SimpleAttributeModifier("onclick", "return confirm('are you
> sure?');"));
> --
>
> However, weather I click 'Cancel' or 'OK', the code in the onSubmit()
> method
> never gets executed.
>
> I'm stuck, I can't believe such a framework does not support this basic
> feature O_o I must be missing something obvious ^^"
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/SubmitLink-with-confirmation-dialog-tp3487505p3488329.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>


-- 
Pedro Henrique Oliveira dos Santos


Re: SubmitLink with confirmation dialog

2011-05-01 Thread scorpio2002
Dear Martin,
thank you for answering. I tried something like this:

--
SubmitLink link = new SubmitLink("link") {
public void onSubmit() { /* my stuff */}
}

link.add(new SimpleAttributeModifier("onclick", "return confirm('are you
sure?');"));
--

However, weather I click 'Cancel' or 'OK', the code in the onSubmit() method
never gets executed.

I'm stuck, I can't believe such a framework does not support this basic
feature O_o I must be missing something obvious ^^"
--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/SubmitLink-with-confirmation-dialog-tp3487505p3488329.html
Sent from the Users forum mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: SubmitLink with confirmation dialog

2011-05-01 Thread Martin Grigorov
Hi,

On Sun, May 1, 2011 at 11:10 AM, scorpio2002  wrote:
> Hi there,
> I have a SubmitLink and I'd like to add a very simple confirmation dialog to
> it? Any way of doing so?
>
> I've tried to add a SimpleAttributeModifier, but it overwrites the behaviour
> in the onSubmit method of the submitlink. I think there must be an easy and
> clean way of doing this.
SimpleAttributeModifier("onclick", yourJsHere) is the way if you want
to use JavaScript alert(). onSubmit() method is called at server side
only if onclick at the client side returned true.
>
> Thank you.--
> View this message in context: 
> http://apache-wicket.1842946.n4.nabble.com/SubmitLink-with-confirmation-dialog-tp3487505p3487505.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



SubmitLink with confirmation dialog

2011-05-01 Thread scorpio2002
Hi there,
I have a SubmitLink and I'd like to add a very simple confirmation dialog to
it? Any way of doing so?

I've tried to add a SimpleAttributeModifier, but it overwrites the behaviour
in the onSubmit method of the submitlink. I think there must be an easy and
clean way of doing this.

Thank you.--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/SubmitLink-with-confirmation-dialog-tp3487505p3487505.html
Sent from the Users forum mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org