As far as I can tell--and I realize there is a good chance I have missed something--even with nested forms or buttons set to setDefaultFormProcessing(false) there is no way to create a functionality like the Gmail sign-up page with it's "Check Availability" button. Basically what I'm trying to do is this: ------- SIGNUP PAGE:
Username: ________ [button: checkAvailability] [label: "available: yes or no"] Pass 1: _________ Pass 2: _________ Email Addr: _________ (etc....) [submit button: createAccount(submits form, with validators; on success redirects to new "Yippee, account created!" page)] -------- The idea here is that pressing the checkAvailability button results in an Ajax request that responds with the label indicating to the user if this username is available or not. This should NOT call the whole form's onSubmit(). Pressing enter in any text input field here will submit the whole form (this is how Gmail Sign-up does it). The problem I encountered is that, unlike with the non-Ajax class Button, AjaxFallbackButton and AjaxButton do not get anything out of a TextField on when accessed from the Ajax(Fallback)Button's onSubmit() field in instances where the whole form is not submitted. The non-Ajax button does require, it should be noted, a call to someTextField.updateModel(), which works fine, but when someTextField.updateModel() is used with the Ajax(Fallback)Button, then you get a NullPointerException. I did find a way around this however. The Button class, which of course includes the AjaxFallbackButton and AjaxButton classes that directly inherit from it, has a delegateSubmit() method that can be overridden. The javadoc for Wicket's Button class says: When you add a Wicket Button to a form, and that button is clicked, by default the button's onSubmit method is called first, and after that the form's onSubmit method is called. If you want to change this (e.g. you don't want to call the form's onSubmit method, or you want it called before the button's onSubmit method), you can override Form.delegateSubmit. Therefore to take advantage of this I created two classes: AjaxFallbackButtonCustom and FormCustom. One good thing is that FormCustom will handle the all other components the same as before. AjaxFallbackButton custom implements the interface SubmitControl which is required so that the FormCustom knows it can check whether or not it should submit the whole form when the button is used. Once you are using both of these, you can perform Ajax requests where you retrieve text from a TextField or TextArea without submitting a whole form as you previously could not. I hope I have explained this somewhat clearly. I have included a link to a quickstart demonstrating this with the classes and interface I created. With the quickstart I have put in some println's to make it easy to follow what's being called and when. Please let me know if I have missed an easier way to do this, or if any of you committers would be interested in working this funcitonality into the Wicket codebase. QUICKSTART HERE: http://cosmiao.com/jps/wicket-quickstart.zip It is all demonstrated on the Home page. Thanks, Jamie -- View this message in context: http://www.nabble.com/Wicket---Ajax%28Fallback%29Button-and-Form---possible-solution-to-problem-tp20373644p20373644.html Sent from the Wicket - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
