It’s really not that complex. The form has invalid input, something happens and the model object changes the state of said input, the form does not reflect the new model changes. I was just hoping for something automatic.
-Lon On Wed, Jun 21, 2017 at 9:53 PM, Sven Meier <s...@meiers.net> wrote: > Hi Lon, > > whatever you are trying to do, it's sounds too complicated. > > FormComponents keep invalid input. That's an essential feature. Clear the > input when you no longer want it. > You can use your own implementation that clears invisible components too. > > I fail to see what that has to do with models. Yes, modelchanged clears > the input too, but I wouldn't mix these two aspects. > > Have fun > Sven > > > > Am 21. Juni 2017, 22:54, um 22:54, Lon Varscsak <lon.varsc...@gmail.com> > schrieb: > >Digging in a little deeper, I learned that if my data comes from the > >forms > >model (which is not how I’m currently doing things), and then create a > >new > >model, everything works as I’d expect. > > > >So in my case, I have a bunch of FormComponents that use a > >PropertyModel to > >do their work. Rather than visiting all of the FormComponents and > >calling > >modelChanged() is there a better way to do this? I’m not so keen on > >CompoundPropertyModel (although I can’t articulate why yet :P)…probably > >because I may have more than one model for a given page. > > > >So I’m thinking of a nested model for my object(s) storing them in > >ivars, > >and then replacing those when I show. I’m just not sure if there’s an > >existing class that will let me use a model as a basis for another > >model > >(not that that seems hard to write). So I’m looking for what others > >are > >doing. > > > >Thanks! > > > >-Lon > > > >On Wed, Jun 21, 2017 at 1:04 PM, Lon Varscsak <lon.varsc...@gmail.com> > >wrote: > > > >> 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 <s...@meiers.net> 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: users-unsubscr...@wicket.apache.org > >>> For additional commands, e-mail: users-h...@wicket.apache.org > >>> > >>> > >> >