If you use an AjaxButton you can use the AjaxRequestTarget like so:

AjaxButton submitButton = new AjaxButton("submit") {
        protected void onSubmit(AjaxRequestTarget target, Form form) {
        
        if(save(form)) {
                //successful
                                
        } else {
                String js = "alert('Failed');";
                target.appendJavascript(js);
        }
                                
        }
};

A custom save() method processes the form and returns true or false. Could also do it in the onSubmit method if you prefer. So long as you return some sort of status, then do the appendJavascript()....



cheers,
Steve







On 5 Jan 2009, at 15:50, Les Hazlewood wrote:

I should clarify, just in case, that the alert/popup I'm talking about is shown AFTER an unsuccessful submission, NOT before the form is allowed to submit (a common case, such as using javascript form validation - that's not
what I'm looking for :) ).

On Mon, Jan 5, 2009 at 10:49 AM, Les Hazlewood <[email protected]> wrote:

Hi all,

I have a quick question that I hope is easily answered by some of the
Wicket gurus on this list :)

I have a simple requirement to show a popup dialog if form submission
fails. Think of it as the feedback panel that usually shows error messages,
but in a popup instead of embedded into the page.

I've been digging in the depths of Wicket Javascript support (wiki, mailing list searches, etc) to see if I can show a dead simple javascript alert dialog instead of the feedback panel, but I'm having a hard time actually finding a concrete area where I should focus my efforts or how to show that
alert in the event of a failure only.

Can anyone tell me how this is done or point to me to where I might be able
to read to make this happen?

The popup can be a simple alert dialog for starters, but should probably evolve to some sexy CSS z-indexed panel later on. This is ultimately due to supporting a very small login form in the home page. Any error messages
wouldn't fit in or near that login form - or they'd just make that
particular div (and the page around it) look really ugly if the feedback
were embedded in the html.

Any help or guidance to resources is much appreciated!

Thanks,

Les


Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to