Re: form processing adding new inputs with an ajax onupdate
Hi Paul, Thanks for the suggestion I'll check that out, Cheers Simon -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/form-processing-adding-new-inputs-with-an-ajax-onupdate-tp4658758p4658856.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: form processing adding new inputs with an ajax onupdate
I never used onConfigure() but conform it's API is called once per request on a component before is about to be rendered. Thus your original code: @Override public void onConfigure() { setVisible(isOngoingService()); } Is only called once if I'm not mistaken. Whereas you want the field to toggle so it must be called more than once. Thus onUpdate() would do the job you want: @Override protected void onUpdate(AjaxRequestTarget target) { provisionDefaultPeriod.setVisible(isOngoingService()); target.add(provisionDefaultPeriod); } I might be mistaken, but since Wicket is open source code feel free to poke around it and understand it better. On Tue, May 14, 2013 at 5:18 AM, Simon B wrote: > Hi Paul, > > I was mistaken. I apologise. > > Previously I hadn't completely removed the onConfigure method from the form > component and simply called the setVisible in the onUpdate method of the > AjaxFormComponentUpdatingBehavior("onchange") / AFCUB("onchange"). > > So your suggestion worked! > > Thank you very much. > > I would still really like to understand why the onConfigure way of setting > the visibility of the component didn't work, does anybody have any idea > about this? > > Cheers > > Simon > > > > -- > View this message in context: > http://apache-wicket.1842946.n4.nabble.com/form-processing-adding-new-inputs-with-an-ajax-onupdate-tp4658758p4658779.html > Sent from the Users forum mailing list archive at Nabble.com. > > - > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > For additional commands, e-mail: users-h...@wicket.apache.org > >
RE: form processing adding new inputs with an ajax onupdate
Hi Paul, I was mistaken. I apologise. Previously I hadn't completely removed the onConfigure method from the form component and simply called the setVisible in the onUpdate method of the AjaxFormComponentUpdatingBehavior("onchange") / AFCUB("onchange"). So your suggestion worked! Thank you very much. I would still really like to understand why the onConfigure way of setting the visibility of the component didn't work, does anybody have any idea about this? Cheers Simon -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/form-processing-adding-new-inputs-with-an-ajax-onupdate-tp4658758p4658779.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
RE: form processing adding new inputs with an ajax onupdate
Hi Paul, Thanks for your suggestion, hadn't tried that, but I have now and it doesn't fix my problem. I use the idiom rather than simply calling Because: 1. depending on the situation it can lead to many setVisible calls in different parts of the page 2. it localises the visible setting to the component to which it applies 3. i don't need to pepper the code with lots of references to the component whose visibility is to be set 4. http://wicketinaction.com/2011/11/implement-wicket-component-visibility-changes-properly/ Thanks anyway for your suggestion, Cheers Simon -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/form-processing-adding-new-inputs-with-an-ajax-onupdate-tp4658758p4658778.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
RE: form processing adding new inputs with an ajax onupdate
Have you tried: provisionDefaultPeriod = new DropDownChoice("provisionDefaultPeriod", new PropertyModel(getTypedModel(), "provisionDefaultPeriod"), activeTimePeriods, renderer); // drop down for choosing the service commercialServiceInput.add(new AjaxFormComponentUpdatingBehavior("onchange") { @Override protected void onUpdate(AjaxRequestTarget target) { provisionDefaultPeriod.setVisible(isOngoingService()); target.add(provisionDefaultPeriod); } }); It seems much cleaner to me. ~ Thank you, Paul Bors -Original Message- From: Simon B [mailto:simon.bott...@gmail.com] Sent: Monday, May 13, 2013 2:47 PM To: users@wicket.apache.org Subject: form processing adding new inputs with an ajax onupdate Hi, I have a form with several inputs one is a DropDownChoice with an AjaxFormComponentUpdatingBehavior("onchange") / AFCUB("onchange") Behavior added to it. When the user changes the DropDownChoice, depending on the value a previously non visible field is displayed via the AFCUB("onchange") onUpdate(AjaxRequestTarget) method, which the user must then fill in. Roughly the code is like this This works fine on the browser the new input fields appear etc, but when the form is then submitted manually with the inputs visible on the screen, their models do not reflect the values selected by the user. Is there something that I need to do in the onUpdate method of the AFCUB("onchange") so the manually submitted Form of the Page reflects the new visibility hierarchy that has been changed via the AFCUB("onchange") ? Any help or clarification much appreciated Cheers Simon -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/form-processing-adding-new-inputs -with-an-ajax-onupdate-tp4658758.html Sent from the Users forum mailing list archive at Nabble.com. - 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