You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wicket.apache.org by Clint Checketts <ch...@gmail.com> on 2011/05/16 23:33:06 UTC

FormComponent convertInput

 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

RE: FormComponent convertInput

Posted by "Checketts, Clint" <Cl...@usaa.com>.
Sorry I had meant to send this to the user's mailing list. Please ignore.

-----Original Message-----
From: Clint Checketts [mailto:checketts@gmail.com] 
Sent: Monday, May 16, 2011 4:33 PM
To: dev
Subject: FormComponent convertInput

 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