For example of how you could validate a form given multiple form fields take a 
look at how EqualInputValidator is implemented.

You would have to keep references to the form fields that are related and 
return them as an array via IFormValidator. getDependentFormComponents() of 
your own IFormValidator implementation. Then you can add as many of those you 
want to your form.

Wicket form processing:

 -------      ----------      ---------      ----------      --------      
------------ 
| Start | -> | required | -> | convert | -> | validate | -> |  push  | -> | 
onSubmit() |
|       |    |  checks  |    |  input  |    |  input   |    |  input |    |     
       |
 -------      ----------      ---------      ----------      --------      
------------ 
                  |              |                |              |              
        
                 fail           fail             fail           fail       
----------- 
                  |              |                |              |        | 
onError() |
                   - - - - - - - - - - - - - - - - - - - - - - - - - - -> |     
      |
                                                                           
-----------

I recommend reading "Wicket in Action" (http://manning.com/dashorst/) or any 
other books listed on Wicket's website (http://wicket.apache.org/learn/books/).

~ Thank you,
Paul Bors | Software Engineer | Knoa Software | 5 Union Square West, New York , 
NY 10003 | O: 212-807-9608 | www.knoa.com


-----Original Message-----
From: Tobias Knierim [mailto:[email protected]] 
Sent: Tuesday, July 17, 2012 6:04 AM
To: [email protected]
Subject: Re: Validating form components in a refreshing view

Hi Josh,

you're right,
I haven't put any in this example because I am really not sure how I should 
accomplish this.
If I choose a FormValidator with the FormComponents textOne and textTwo, I can 
just compare the values of one row.

I will extend my example later.

Tobi


2012/7/17 Josh Kamau <[email protected]>:
> Hi Tobi ;
>
> I cant see any Validation code..
>
> Josh.
>
> On Tue, Jul 17, 2012 at 12:01 PM, Tobias Knierim < 
> [email protected]> wrote:
>
>> Hi Josh,
>>
>> I just created a little example of how my application is working:
>> I want to compare value2 from Entry1 with value1 from Entry2 and so on.
>>
>> Any ideas?
>>
>>
>> Form<Values> form = new Form<Values>("form");
>>                 add(form);
>>
>>                 RefreshingView<Entry> refreshingView = new 
>> RefreshingView<Entry>("list", values) {
>>
>>                         @Override
>>                         protected Iterator<IModel<Entry>> getItemModels() {
>>                                 List<Entry> entryList = 
>> values.getObject().getEntryList();
>>
>>                                 ModelIteratorAdapter<Entry> mia = new
>> ModelIteratorAdapter<Entry>(entryList.iterator()) {
>>
>>                                         @Override
>>                                         protected IModel<Entry> 
>> model(Entry object) {
>>                                                 return new 
>> CompoundPropertyModel<Entry>(object);
>>                                         }
>>                                 };
>>                                 return mia;
>>                         }
>>
>>                         @Override
>>                         protected void populateItem(Item<Entry> item) {
>>                                 IModel<Entry> model = 
>> item.getModel();
>>
>>                                 item.add(new 
>> TextField<String>("textOne", new PropertyModel<String>(model, 
>> "value1")));
>>                                 item.add(new 
>> TextField<String>("textTwo", new PropertyModel<String>(model, 
>> "value2")));
>>                         }
>>
>>                 };
>>
>>                 form.add(refreshingView);
>>
>> Tobi
>>
>>
>> 2012/7/17 Josh Kamau <[email protected]>:
>> > Tobi ;
>> >
>> > May be you can paste some code to show how you are constructing the 
>> > forms...
>> >
>> > I believe if you just add the validators to the components and then
>> submit
>> > the forms, it just works..
>> >
>> > Josh.
>> >
>> > On Tue, Jul 17, 2012 at 10:22 AM, Tobias Knierim < 
>> > [email protected]> wrote:
>> >
>> >> Hi Josh,
>> >>
>> >> The whole view is wrapped in one form.
>> >>
>> >> Greetings
>> >> Tobi
>> >>
>> >> Am 17.07.2012 um 09:04 schrieb Josh Kamau <[email protected]>:
>> >>
>> >> > Hi ;
>> >> >
>> >> > Is the whole listview wrapped in 1 form or there is a form for 
>> >> > each
>> row?
>> >> >
>> >> > Josh.
>> >> >
>> >> > On Tue, Jul 17, 2012 at 10:02 AM, Tobias Knierim < 
>> >> > [email protected]> wrote:
>> >> >
>> >> >> Hi there,
>> >> >> I'm new to wicket and have a problem I can't find out for myself.
>> >> >> Maybe some of you can help me out with this.
>> >> >>
>> >> >> I have a refreshingview with input fields each row. I can add 
>> >> >> new
>> rows
>> >> >> on click of a button, but when I submit the form, I want to 
>> >> >> validate
>> 2
>> >> >> input fields from different rows. Everything I tried so far 
>> >> >> hasn't worked out, because I was only able to validate values from one 
>> >> >> row.
>> >> >>
>> >> >> Is it even possible to do something like this?
>> >> >>
>> >> >>
>> >> >> Greetings
>> >> >> Tobi
>> >> >>
>> >> >> ---------------------------------------------------------------
>> >> >> ------ To unsubscribe, e-mail: 
>> >> >> [email protected]
>> >> >> For additional commands, e-mail: [email protected]
>> >> >>
>> >> >>
>> >>
>> >> ------------------------------------------------------------------
>> >> --- To unsubscribe, e-mail: [email protected]
>> >> For additional commands, e-mail: [email protected]
>> >>
>> >>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>>
>>

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to