wicket-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bertrand Guay-Paquet <ber...@step.polymtl.ca>
Subject Re: FormComponent convertInput for children FormComponets
Date Thu, 19 May 2011 12:51:54 GMT
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-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Mime
View raw message