On Mon, 2009-04-27 at 06:43 -0400, Willis Blackburn wrote:
> Thorsten,
> 
> Look at the Wicket class called EqualInputValidator for guidance.
> 
> You have to add it to the form, not to the individual fields.
> 

Thanks.

Meanwhile I found a working solution. Will post it now. 

salu2

> W
> 
> 
> On Apr 27, 2009, at 6:16 AM, Thorsten Scherler wrote:
> 
> > Hi all,
> >
> > I have a question about validating one field with another.
> >
> > I have a form that ask for the start page and for the end page of an
> > article. I need to validate whether the startPage is lesser or equal  
> > to
> > the endPage.
> >
> > I could do this in public void onSubmit() {...} of the form like:
> > public void onSubmit() {
> > if(model.getStartPage()>model.getEndPage()){
> >      this.error("The startPage cannot be bigger then the endPage");
> >    }
> > ...
> > }
> >
> > However I wonder if that is not cleaner with a validator. My problem  
> > is
> > ATM that I have not found an example that shows how to validate a  
> > field
> > comparing it to another field in the same form.
> >
> > In pseudo code:
> >
> > RequiredTextField start = new RequiredTextField("startPage",
> > Integer.class);
> > add(start);
> > RequiredTextField end = new RequiredTextField("endPage",  
> > Integer.class);
> >
> > // the next line does not exits but would be what I need
> >
> > NumberValidator max = NumberValidator.minimum(start);
> > end.add(max);
> > add(end);
> >
> > What is the best way to implement such a validation?
> >
> > TIA for any tips.
> >
> > salu2
> > -- 
> > Thorsten Scherler <thorsten.at.apache.org>
> > Open Source Java <consulting, training and solutions>
> >
> > Sociedad Andaluza para el Desarrollo de la Sociedad
> > de la InformaciĆ³n, S.A.U. (SADESI)
> >
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> > For additional commands, e-mail: users-h...@wicket.apache.org
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
> 
-- 
Thorsten Scherler <thorsten.at.apache.org>
Open Source Java <consulting, training and solutions>

Sociedad Andaluza para el Desarrollo de la Sociedad 
de la InformaciĆ³n, S.A.U. (SADESI)





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

Reply via email to