Yes, you can also push the state instead of pulling it, which besides is 
preferrable in terms of efficiency (as onConfigure() is only called once per 
request whereas isVisible() is potentially called many time):

TextField<String> textField = new TextField<String>("textField") {
    @Override
    protected void onConfigure() {
        super.onConfigure();
        setVisible(condition);
    }
};

You can also call textField.setVisible(...) in the Page's or Panel's 
onConfigure(), but then you need a reference to the textField (property of the 
page or panel). Or - if possible - you can group your FormComponents into a 
WebMarkupContainer an set the visibility there.

   -Tom



On 05.06.2012 at 16:51 Bob Schlärmann wrote:

> Hello,
> 
> A question about form processing: is it possible to do conditional form 
> validation without overriding FormComponent#isRequired?
> 
> I have a form with about 5 different form components (e.g. textfields, 
> dropdown, radiobutton). These fields are only required if a RadioGroup has a 
> certain value.
> 
> I've read the solution given in 
> https://cwiki.apache.org/WICKET/conditional-validation.html. But this means I 
> have to subclass all form components  and override isRequired. Is there an 
> easier solution?
> 
> Currently I'm using an Ajax call and disable the container of the optional 
> components, however that doesn't work if Javascript is disabled (also not 
> safe presumably).
> 
> Best regards,
> 
> Bob


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to