Yeah, I had convinced myself on the way home that it was a feature too…until I thought about the model data having changed.
So I looked into the form.clearInput() (thanks for that tip) and the model object is in a particular state that has field is hidden at the time I do the clear. So it’s that my model object has changed and my UI doesn’t reflect the current state (because of this feature) once they make the field visible. It just feels like a little bit of an odd case (not that I know how it would be better). I guess I’ll switch to not reusing the component (which is fine), I just think I’m going to bit by this more than once. :) -Lon On Wed, Jun 21, 2017 at 10:44 AM, Sven Meier <[email protected]> wrote: > Hi, > > if you reuse a component after a submit with validation errors, you'll > have to reset all form components. > Otherwise the form components will render their previous invalid input - > this is an intended feature, to give the user the ability to edit his > previous input. > > Calling clearInput() on the form itself has no impact (which also >> surprised me). >> > > That surprises me too, as this should work. Please check > Form#clearInput()'s source: your components have to be visible, otherwise > this call does nothing. > > Have fun > Sven > > > > Am 21.06.2017 um 19:29 schrieb Lon Varscsak: > >> I have a scenario where I have a form and the user puts in a bad value in >> FieldA, and then also puts in proper values in FieldB and FieldC. FieldB >> and FieldC never receive their values (in the model object), I’m assuming >> because the form processing stops at the error for FieldA. The user >> dismisses the model (which just makes the component not visible and does >> an >> Ajax refresh). >> >> The user then goes in to edit the data again (same component, just made >> visible and refreshed with an Ajax request). Before the panel is shown >> the >> underlying model object is swapped out with a new one (that has no values >> in all 3 fields), however, when it appears the data is as it was >> previously, including the unsaved values in FieldB and FieldC (from the >> first pass). >> >> This surprised me a bit (not that I’m anywhere near a wicket expert), I >> would have assumed that since the model object changed that the form >> components would refresh. So in hacking around, I found that if I visit >> all the FormComponents and call clearInput() on them, the form will >> display >> the correct values (blank in this case). Calling clearInput() on the form >> itself has no impact (which also surprised me). >> >> What’s the proper way to handle this case? I feel like while I have a >> working case, it’s a little clunky. >> >> -Lon >> >> > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > >
