I don't see how you can do that.  Validators no longer know about models.
That's all hidden behind IValidatable.getValue() now.  I think that's
good,
because they are more general now, but it's a limitation for this use
case.


ahh ok.
But if you are already in the validator then you also don't really  know
about components
so where  do you do then the call to component.getRootModel()?
Because  the place where you do that now. should also be able to do the
while loop
or am i mistaken?


and maybe implement a public getRootModel() for convenience that does
getRootModel(getModel()), which is what I'm doing.


that would be better then
opening up the getRootModel with the model param is a bit strange. because
what to give to it?
then it is more a static helper method.



Actually, I think the code for this late-bound lazy model that saves space
is fairly straightforward.  Something like (notice no assignment to
this.model,
so the wrapper is recreated every time):

       public IModel getModel()
       {
               // If model is null
               if (model == null)
               {
                       // always recreate model wrapper for late-bound
models to save space
                       return initModel();
               }

               return model;
       }

if we do this then all the wrap models should really have the right hashcode
and equals implementations.
Because we don't know what happens with those models. Because then every
call to it will generate a new one.
If that model is put into a hashmap or something then this could be come
pretty ugly.


Another maybe better option would be to null out any models that were
created
by initModel on detach().  Yet another boolean to do that, but it's more
space
efficient and doesn't always recreate the model wrapper either... assuming
we've
got the extra bit still, which at first glance it looks like we do...  this
seems like
the way to go...

This we could do (one made per request)
and i dont think we need a boolean because we already know what models we
can clear:
implementing IWrapModel
(and maybe some other check if the getParentModel() ==
IWrapModel.getNestedModel())

So it won't cost is any extra space.

johan

Reply via email to