Johan Compagner wrote:
> 
> It could be protected if you like. (maybe final then?)
> But it is a very simple method that you can implement very easy in your
> validator self ofcourse.
> (then you also don't have a back call to component)
> 

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.

The way I have implemented this now, the validator is not aware of any of
this.
It has a constrainedClass property, which is set for CompoundPropertyModels
when the component attaches.  This is a bit ugly, but necessary because
there's
no way through the validation API to get the model, only the object to be
validated,
and there's no way in the constrained field to get the class of the model
because
that may be unknown until the compound property model binding occurs via
initModel().  Make sense?  Simplest thing is to make getRootModel(IModel)
protected
and maybe implement a public getRootModel() for convenience that does 
getRootModel(getModel()), which is what I'm doing. 


Johan Compagner wrote:
> 
> No not really, generics and the previous compound don't really work
> together
> correctly and then we need the Component param back in the normal model 
> which is ugly and for the compound param very ambiguous what to put in it.
> currently component.getModelObject() is always
> component.getModel().getObject()
> 

I didn't mean we should have a component parameter.  I was wondering more
if the wrapper couldn't be transient (construct a wrapper every time we're
asked
for the model and then let the wrapper get GC'ed rather than holding on to
it.
if that's possible, it could mean memory savings, but also getting rid of
that 
interface too)

-- 
View this message in context: 
http://www.nabble.com/getRootModel-and-tf3476307.html#a9707110
Sent from the Wicket - Dev mailing list archive at Nabble.com.

Reply via email to