I finally had a chance to create a quickstart and play with it. The issue
happens when my FormComponentPanel has its own form. So it appears that the
inner form delays the processing of those inner elements.

Once I removed the inner form so the child FormComponents were added
directly to my FormComponentPanel the getConvertedInput worked as expected.

<wicket:panel>
<form wicket:id="form">   <----------------------------This inner form in
the panel was the culprit!
<div wicket:id="namesList">
    <label wicket:id="label"></label>
    <input wicket:id="name" />

</div>
</form>
</wicket:panel>

So this leads into another question: Is the a better solution to making it
work if I can't remove the inner form?


-Clint

On Thu, May 19, 2011 at 11:16 AM, Clint Checketts <checke...@gmail.com>wrote:

> I'll validate my code again. It is running on Wicket 1.4.1 so maybe it was
> linked to the older version.
>
> Thanks everyone for the help, its good to know that it is working correctly
> for others.
>
> -Clint
>
> On Thu, May 19, 2011 at 7:51 AM, Bertrand Guay-Paquet <
> ber...@step.polymtl.ca> wrote:
>
>> Hi,
>>
>> I am doing the same kind of processing and it works fine. I have a
>> FormComponentPanel with children FormComponentPanels. Here is what the
>> convertInput() method looks like for the "root" FormComponentPanel:
>> protected void convertInput() {
>>    // Retrieve all children
>>    final List<Foo> fooList = new ArrayList<Foo>();
>>    foosRepeater.visitChildren(FooFormFields.class,
>>            new IVisitor<FooFormFields, Void>() {
>>                @Override
>>                public void component(FooFormFields a_object, IVisit<Void>
>> a_visit) {
>>                    Foo foo = a_object.getConvertedInput();
>>                    if (foo != null) {
>>                        fooList.add(foo);
>>                    }
>>                }
>>            });
>>    setConvertedInput(fooList);
>> }
>>
>> All the children validators are called and their convertedInput is
>> properly set.
>>
>> Bertrand
>>
>>
>>
>> On 16/05/2011 5:35 PM, Clint Checketts wrote:
>>
>>>   I have a FormComponentPanel that contains multiple child formcomponent.
>>> The purpose of this panel is to be able to add in several cihldren
>>> dynamically. The end model is supposed to be the list from all the
>>> children
>>> component. I get the value in my convertInput() method by iterating over
>>> all
>>> the children components, calling each one's getConvertedInput()
>>>
>>> Here's the problem, the child component's values haven't convertedTheir
>>> input at that point, so i call 'validate()' on each one to trigger that
>>> coversion.  Is that the right way to approach this? Am i causing
>>> unneeded/duplicate processing?
>>> .
>>>
>>> protected void convertInput() {
>>>   final ArrayList<T>  convertedInputList = new ArrayList<T>();
>>>   inForm.visitFormComponents(new IVisitor() {
>>>    public Object formComponent(IFormVisitorParticipant formComponent) {
>>>     if (formComponent instanceof FormComponent<?>) {
>>>      FormComponent<T>  fc = (FormComponent<T>) formComponent;
>>>      *fc.validate();
>>> *     T convertedInput =  *fc.getConvertedInput();
>>> *     if(null != convertedInput){
>>>       convertedInputList.add(convertedInput);
>>>      }
>>>     }
>>>     return Component.IVisitor.CONTINUE_TRAVERSAL;
>>>    }
>>>   });
>>>   setConvertedInput(convertedInputList);
>>>  }
>>>
>>>  Thanks,
>>>
>>> -Clint
>>>
>>>
>>  ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
>> For additional commands, e-mail: users-h...@wicket.apache.org
>>
>>
>

Reply via email to