I've got a form that is a simple collection of TextFields. I'd like to validate that form through AJAX prior to submission and redraw the TextFields which have a Behavior attached to them that changes the font color if they are invalid. To do that I've added an AjaxFallbackButton that looks like this:

                AjaxFallbackButton button = new AjaxFallbackButton (id, form) {
                        @Override
                        protected void onSubmit(AjaxRequestTarget target, Form 
form) { }
                        
                        @Override
                        protected void onError(final AjaxRequestTarget target, 
Form form) {
                                // Redraw the feedback panel
                                if(feedbackPanel!=null)
                                        target.addComponent(feedbackPanel);
                                
                                // Redraw all child textfields
                                target.addChildren(form,TextField.class);
                        }
                };

This works perfectly the first time it is clicked. However, if the user does not correct the error or if there is a second error no validation occurs on the second submission. If I comment out the "addChildren" call the form works as I would expect and all errors are shown in the FeedbackPanel through multiple submissions. Doing anything that visits the form components seems to cause them to show as valid the next time the form is submitted (I've also tried using Form.visitFormComponents() and MarkupContainer.iterator() with similar results).

Do I need to do something to reset the state of the form after visiting the child components or could this be a bug? Is there a better way to do this that I'm missing? It happens in both 1.3b3 and 1.3b4.

Note that I can't use AjaxFormValidatingBehavior because I need all the validation to happen in one pass when the form is submitted not as the user types things in.

Thanks,
-Mike
--
Mike Comb
Director of Engineering
SoftCoin, Inc
[EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to