Thanks a lot for your input guys, it really helped me a lot. I chose to use
Kent's approach using a Validator that - by the way - could not be a static
class as I had to access member variables outside the Validator.

Thanks again and have a nice day

Michael


Kent Tong wrote:
> 
> 
> Gerolf Seitz wrote:
>> 
>> ditch the form and let CaptchaPanel extend FormComponentPanel. for the
>> captcha and do a check for the form in onBeforeRender (since it's not yet
>> added to the hierarchy in the constructor).
>> just use "getForm();" to check for the existence of an ancestor form.
>> this
>> method throws an exception if no form was found.
>> 
> 
> I'd suggest that it extend Panel, not FormComponentPanel as there is no
> composite data structure here. The best place to validate the input is
> in a custom validator. Here is some sample code (there is also step-by-
> step instruction on validation in my tutorials; see my signature):
> 
> public class CaptchaPanel extends Panel {
>       private static class CaptchaValidator extends AbstractValidator {
>               protected void onValidate(IValidatable validatable) {
>                       String value = (String) validatable.getValue();
>                       if (value matches the image) {
>                               return;
>                       }
>                       error(validatable);
>               }
>       }
>       public CaptchaPanel(String id) {
>               super(id);
>               RequiredTextField t = new RequiredTextField("captchaInput", new
> Model());
>               t.add(new CaptchaValidator());
>               add(t);
>               add(new Image("captchaImage", ...));
>       }
> }
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Decouple-parts-of-a-form-tf4591493.html#a13114625
Sent from the Wicket - User mailing list archive at Nabble.com.


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

Reply via email to