You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Julian Sinai <js...@yahoo.com> on 2009/04/21 21:00:15 UTC

Defer call to preDecorateScript() till onSubmit() is called?

Hi, I need to display a confirmation message to the user before submitting a form. It's pretty standard to use the code below when the message is known at the time of button or link construction. But what about when the message must be synthesized at the time of the button click? I've tried using a model, but that didn't help. I would appreciate any help.

Thanks,
Julian


@Override
protected IAjaxCallDecorator getAjaxCallDecorator()
{
return new AjaxPreprocessingCallDecorator(super.getAjaxCallDecorator())
{
@Override
public CharSequence preDecorateScript(CharSequence script)
{
 return "if(!confirm('" + message
      + "')) return false;" + script; 
}
};
}


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


Re: Defer call to preDecorateScript() till onSubmit() is called?

Posted by Jeremy Thomerson <je...@wickettraining.com>.
You'd probably need to return script that can create the message
client-side, for instance, if you're creating the message based on fields in
the form.  I'm not sure if you need to generate the message server-side.

--
Jeremy Thomerson
http://www.wickettraining.com



On Tue, Apr 21, 2009 at 2:00 PM, Julian Sinai <js...@yahoo.com> wrote:

>
> Hi, I need to display a confirmation message to the user before submitting
> a form. It's pretty standard to use the code below when the message is known
> at the time of button or link construction. But what about when the message
> must be synthesized at the time of the button click? I've tried using a
> model, but that didn't help. I would appreciate any help.
>
> Thanks,
> Julian
>
>
> @Override
> protected IAjaxCallDecorator getAjaxCallDecorator()
> {
> return new AjaxPreprocessingCallDecorator(super.getAjaxCallDecorator())
> {
> @Override
> public CharSequence preDecorateScript(CharSequence script)
> {
>  return "if(!confirm('" + message
>      + "')) return false;" + script;
> }
> };
> }
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>