You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Federico Fanton <ff...@ibc.it> on 2007/08/07 10:57:03 UTC
Re: Showing an alert
On Thu, 2 Aug 2007 18:25:28 +0200
Federico Fanton <ff...@ibc.it> wrote:
> > I'm sorry, I'm looking for a way to show an alert dialog when a condition is met.. For example, the user fills in a "search form", submits it and if there's no data matching the query, a "no data found!" should pop up.. I'd like to use something like the "alert" JavaScript function, but I'm a bit confused about where to put it.. ^^;
>
> class alert extends abstractbehavior {
> boolean istemporary() { return false; }
> void renderhead(iheaderresponse r) {
> renderonloadjavascript("alert('error!');"); }
> }
>
> form searchform=new form(...) {
> onerror() { add(new alert(); }
> }
I tried as you suggested, but I'm facing a little problem.. If I'm not mistaken, "onError" is called on form validation, so I added my check for "no data" in a FormValidator.. My problem is that this check needs the form CompoundPropertyModel to be up to date with the form contents, but form validation is called *before* the model gets updated.. Am I going the wrong way? :/
Many thanks for your time!
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Showing an alert
Posted by Federico Fanton <ff...@ibc.it>.
On Tue, 7 Aug 2007 10:57:03 +0200
Federico Fanton <ff...@ibc.it> wrote:
> I tried as you suggested, but I'm facing a little problem..
> If I'm not mistaken, "onError" is called on form validation,
> so I added my check for "no data" in a FormValidator.. My
> problem is that this check needs the form CompoundPropertyModel
> to be up to date with the form contents, but form validation is
> called *before* the model gets updated.. Am I going the wrong way? :/
I solved by overriding my button's "onSubmit" with something like
Form f=getForm();
f.process();
// snipped check for data size
if(showAlert){
f.error("no data!");
f.onError();
}
How does it look like? ^^;
Many thanks again for your help!
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org