Re: FormComponent convertInput for children FormComponets
I created https://issues.apache.org/jira/browse/WICKET-3765 and attached a quickstart. I commented out the Form in the quickstart. Just uncomment those lines to see the bug. Regarding the strangeness of the Form in the FormComponent: I may be able to remove the Form. This is an older component that I created over a year ago and finally figured out how to do it correctly when reading the Wicket Cookbook, which exposed this behavior. I may be able to refactor the inner Form out of the FormComponent, but the nature of my component is that the repeating element (as in a TextField) is configurable so it could be a TextField, or some other custom field (which could in turn have a possible inner form) so I want to make it as resilient as possible. Thanks! -Clint On Thu, Jun 2, 2011 at 9:42 PM, Igor Vaynberg wrote: > create a quickstart and we can see if there is an easy fix. at first > glance it seems rather strange to have a form inside a > formcomponentpanel > > -igor > > On Wed, Jun 1, 2011 at 6:56 PM, Clint Checketts > wrote: > > 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. > > > > > >> the panel was the culprit! > > > > > > > > > > > > > > > > > > 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 >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 fooList = new ArrayList(); > >>>foosRepeater.visitChildren(FooFormFields.class, > >>>new IVisitor() { > >>>@Override > >>>public void component(FooFormFields a_object, > IVisit > >>> 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 convertedInputList = new ArrayList(); > inForm.visitFormComponents(new IVisitor() { > public Object formComponent(IFormVisitorParticipant formComponent) > { > if (formComponent instanceof FormComponent) { > FormComponent fc = (FormComponent) 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 > >>> > >>> > >> > > > > - > To unsubscribe, e-mail: users-unsubscr...@wicket.a
Re: FormComponent convertInput for children FormComponets
create a quickstart and we can see if there is an easy fix. at first glance it seems rather strange to have a form inside a formcomponentpanel -igor On Wed, Jun 1, 2011 at 6:56 PM, Clint Checketts wrote: > 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. > > >the panel was the culprit! > > > > > > > > > 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 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 fooList = new ArrayList(); >>> foosRepeater.visitChildren(FooFormFields.class, >>> new IVisitor() { >>> @Override >>> public void component(FooFormFields a_object, IVisit >>> 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 convertedInputList = new ArrayList(); inForm.visitFormComponents(new IVisitor() { public Object formComponent(IFormVisitorParticipant formComponent) { if (formComponent instanceof FormComponent) { FormComponent fc = (FormComponent) 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 >>> >>> >> > - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: FormComponent convertInput for children FormComponets
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.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 fooList = new ArrayList(); >>foosRepeater.visitChildren(FooFormFields.class, >>new IVisitor() { >>@Override >>public void component(FooFormFields a_object, IVisit >> 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 convertedInputList = new ArrayList(); >>> inForm.visitFormComponents(new IVisitor() { >>>public Object formComponent(IFormVisitorParticipant formComponent) { >>> if (formComponent instanceof FormComponent) { >>> FormComponent fc = (FormComponent) 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 >> >> >
Re: FormComponent convertInput for children FormComponets
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 fooList = new ArrayList(); >foosRepeater.visitChildren(FooFormFields.class, >new IVisitor() { >@Override >public void component(FooFormFields a_object, IVisit > 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 convertedInputList = new ArrayList(); >> inForm.visitFormComponents(new IVisitor() { >>public Object formComponent(IFormVisitorParticipant formComponent) { >> if (formComponent instanceof FormComponent) { >> FormComponent fc = (FormComponent) 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 > >
Re: FormComponent convertInput for children FormComponets
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 fooList = new ArrayList(); foosRepeater.visitChildren(FooFormFields.class, new IVisitor() { @Override public void component(FooFormFields a_object, IVisit 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 convertedInputList = new ArrayList(); inForm.visitFormComponents(new IVisitor() { public Object formComponent(IFormVisitorParticipant formComponent) { if (formComponent instanceof FormComponent) { FormComponent fc = (FormComponent) 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
Re: FormComponent convertInput for children FormComponets
maybe you need to set type for each control, I had similar issue. look at the wicket code where the value is set. pozdrawiam Paweł Kamiński kami...@gmail.com pkaminski@gmail.com __
Re: FormComponent convertInput for children FormComponets
OK, if you have validators on your FormComponentPanel, my suggestion won't work. Sven On 05/17/2011 09:28 PM, Clint Checketts wrote: Sven, Having that code in updateModel is too late. The input needs to be converted and set to make it available to validators. The form processing cycle is roughly: 1- User submitts the form 2- Required fields are checked for existence 3- Input is converted 4- Validators run 5- Models get updated 6- onSubmit logic fires I need the logic in the conversion step so it is available in the validation step. -Clint On Tue, May 17, 2011 at 3:06 AM, Sven Meier wrote: Hi Clint, move your code into #updateModel() and set the collected list right into your model. Best regards Sven On 05/16/2011 11: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 convertedInputList = new ArrayList(); inForm.visitFormComponents(new IVisitor() { public Object formComponent(IFormVisitorParticipant formComponent) { if (formComponent instanceof FormComponent) { FormComponent fc = (FormComponent) 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 - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: FormComponent convertInput for children FormComponets
On Mon, May 16, 2011 at 2: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, are you sure that is correct? all children's convertInput should have been called before the parent's... -igor > 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 convertedInputList = new ArrayList(); > inForm.visitFormComponents(new IVisitor() { > public Object formComponent(IFormVisitorParticipant formComponent) { > if (formComponent instanceof FormComponent) { > FormComponent fc = (FormComponent) 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
Re: FormComponent convertInput for children FormComponets
Sven, Having that code in updateModel is too late. The input needs to be converted and set to make it available to validators. The form processing cycle is roughly: 1- User submitts the form 2- Required fields are checked for existence 3- Input is converted 4- Validators run 5- Models get updated 6- onSubmit logic fires I need the logic in the conversion step so it is available in the validation step. -Clint On Tue, May 17, 2011 at 3:06 AM, Sven Meier wrote: > Hi Clint, > > move your code into #updateModel() and set the collected list right into > your model. > > Best regards > Sven > > > On 05/16/2011 11: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 convertedInputList = new ArrayList(); >> inForm.visitFormComponents(new IVisitor() { >>public Object formComponent(IFormVisitorParticipant formComponent) { >> if (formComponent instanceof FormComponent) { >> FormComponent fc = (FormComponent) 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 > >
Re: FormComponent convertInput for children FormComponets
Hi Clint, move your code into #updateModel() and set the collected list right into your model. Best regards Sven On 05/16/2011 11: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 convertedInputList = new ArrayList(); inForm.visitFormComponents(new IVisitor() { public Object formComponent(IFormVisitorParticipant formComponent) { if (formComponent instanceof FormComponent) { FormComponent fc = (FormComponent) 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
FormComponent convertInput for children FormComponets
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 convertedInputList = new ArrayList(); inForm.visitFormComponents(new IVisitor() { public Object formComponent(IFormVisitorParticipant formComponent) { if (formComponent instanceof FormComponent) { FormComponent fc = (FormComponent) formComponent; *fc.validate(); * T convertedInput = *fc.getConvertedInput(); * if(null != convertedInput){ convertedInputList.add(convertedInput); } } return Component.IVisitor.CONTINUE_TRAVERSAL; } }); setConvertedInput(convertedInputList); } Thanks, -Clint