Re: Component initModel() order (design issue?)

2009-10-01 Thread Edmund Urbani
Can't be done, because the component does not yet know its parent during object initialization. initModel/getDefaultModel needs to be called later, when the component knows its place in the hierarchy. by giving the child component a model that obtains the model from its parent (MyTextfield) the

Re: Component initModel() order (design issue?)

2009-10-01 Thread Igor Vaynberg
initmodel isnt called until the first getmodel/object call. why would that happen before the component is added to its parent? -igor On Thu, Oct 1, 2009 at 1:03 AM, Edmund Urbani e...@liland.org wrote: Can't be done, because the component does not yet know its parent during object

Component initModel() order (design issue?)

2009-09-30 Thread Edmund Urbani
Hi, I was just trying to create a component of my own which - in some of my pages - is created without a model. In the initModel() method I would then call super.initModel() and wrap the resulting model for use in a child component. The problem is the initialization order: The child model's

Re: Component initModel() order (design issue?)

2009-09-30 Thread Pedro Santos
The child model's initModel() gets called first There are no especial ordering programing to initModels calls. Basically they are called by public final IModel? getDefaultModel() { IModel? model = getModelImpl(); // If model is null if (model == null) {

Re: Component initModel() order (design issue?)

2009-09-30 Thread Edmund Urbani
You're right, getDefaultModel ensures initialization. I should have suggested that instead of getModel (which is not available in the component class anymore in 1.4.x). However, I did not want to override the initModel() method (and copy most of its code) just for that. So now I solved it by

Re: Component initModel() order (design issue?)

2009-09-30 Thread Igor Vaynberg
why not class mytextefield extends panel { public mytextfield { add(new textfield() { initmodel() { return mytextfield.this.getdefaultmodel(); }}); } } since this is essentially what you want to do - have textfield use the same model as the panel. -igor On Wed, Sep 30, 2009 at 9:47