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 notwhat 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 submissionfails. 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 thatalert in the event of a failure only.Can anyone tell me how this is done or point to me to where I might be ableto 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 messageswouldn't fit in or near that login form - or they'd just make thatparticular div (and the page around it) look really ugly if the feedbackwere embedded in the html. Any help or guidance to resources is much appreciated! Thanks, Les
smime.p7s
Description: S/MIME cryptographic signature
