thanks. it's working, but like this, i always have to overide the
Form.validate() and it won't work with normal Form. What do you think about
this solution:

class MyComponent extends Panel {
  private IFormValidator formValidator;

  setValidation(...){
    formValidator = new IFormValidator(){

      public FormComponent[] getDependentFormComponents() {
        return null;
      }

      public void validate(Form form) {
        if (checkerrors()) {
          error("foo");
        }
      }
    };
  }

  protected void onBeforeRender() {
    if(formValidator != null){
      Form form = (Form) findParent(Form.class);
      form.add(formValidator);
    }
    super.onBeforeRender();
  }
}



igor.vaynberg wrote:
> 
> by default it can only be added to form components but there are things
> you
> can use a visitor - here is some pseudo code
> 
> interface IValidateable { void validate(); }
> 
> class MyForm extends Form {
>    void validate() {
>       super.validate();
>       visit(IValidatable.class, new IVisitor() {
>            Object visit(Component c) {
>                 ((IValidatable)c).validate();
>                 return CONTINUE_TRAVERSAL;
>            }
>        }
> }
> 
> class MyComponent extends Panel implemetns IValidateable {
>     ....
>     void validate(Form f) {
>           if (checkerrors()) {
>               error("foo");
>             }
>      }
> }
> 
> 
> this should get you started, if you dont mind make a wiki page :)
> 
> -Igor
> 
> 
> On 8/27/06, p.jasson <[EMAIL PROTECTED]> wrote:
>>
>>
>> How can I add an validator to a non FormComponent Component? I have my
>> own
>> component derived from Panel and i would like to add validation to it. I
>> would really appreciate if somebody will give me an example.
>>
>> Thanks
>> --
>> View this message in context:
>> http://www.nabble.com/Fom-validation-tf2173006.html#a6008324
>> Sent from the Wicket - User forum at Nabble.com.
>>
>>
>> -------------------------------------------------------------------------
>> Using Tomcat but need to do more? Need to support web services, security?
>> Get stuff done quickly with pre-integrated technology to make your job
>> easier
>> Download IBM WebSphere Application Server v.1.0.1 based on Apache
>> Geronimo
>> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
>> _______________________________________________
>> Wicket-user mailing list
>> Wicket-user@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/wicket-user
>>
> 
> -------------------------------------------------------------------------
> Using Tomcat but need to do more? Need to support web services, security?
> Get stuff done quickly with pre-integrated technology to make your job
> easier
> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
> _______________________________________________
> Wicket-user mailing list
> Wicket-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/wicket-user
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Fom-validation-tf2173006.html#a6011360
Sent from the Wicket - User forum at Nabble.com.


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to