I have a form with a bunch of text fields and a submit button.
I would like to keep the form submit button disabled until the form passes 
validation. The form is currently validated using the  ajaxformvalidation 
behavior.

Is there an out of the box technique to do this? I  copied the 
AjaxFormValidationBehavior class and modified the onSubmit() to add the button 
as enabled when the form has no errors  in it.  Although this works, I would 
like to know if there is an elegant way to achieve this.

I added a DisabledBehavior class that just tags the component that needs to be 
enabled or disabled conditionally. And then onSubmit() I do the following:

getForm().visitChildren(FormComponent.class, new IVisitor() {            public 
Object component(Component component) {                for (Object behavior : 
component.getBehaviors()) {                    if (behavior instanceof 
DisabledBehavior)                        target.addComponent(component);        
        }                return IVisitor.CONTINUE_TRAVERSAL_BUT_DONT_GO_DEEPER; 
           } });

Would appreciate if anyone can suggest a better way to do this.

Thanks.

Reply via email to