for example Component.getModelObject() does this:
// If this component has the root model for a compound model
if (getFlag(FLAG_HAS_ROOT_MODEL))
{
// we need to return the root model and not a property of the
// model
Object result = getRootModel(model);
if ((result instanceof IModel))
{
result = ((IModel)result).getObject(null);
}
return result;
}
// Get model value for this component
return model.getObject(this);
and setModelObject()
modelChanging();
model.setObject(this, object);
modelChanged();
Thats wrong. It should be the same kind of check for that setObject()
And call it will null if it is the root model of itself instead of giving "this" with the call.
johan
On 11/22/05, Christian Essl <[EMAIL PROTECTED]> wrote:
On Tue, 22 Nov 2005 16:10:23 +0100, Anders Peterson
<[EMAIL PROTECTED]> wrote:
> Hi,
>
> There are a couple of things I don't understand.
>
> 1) I have a form using a CompoundPropertyModel with a HashMap as the
> initial model object. When I later (after having made a choice in a
> DropDownChoice) call
>
> this.getForm().setModelObject(aNewModelObject);
>
> nothing in the gui is updated. Typically I have components declared like
>
> tmpForm.add(new TextField(ID_SPAN));
>
> that I'd like to have updated.
>
Component.setModelObject (Object obj) does call IModel.setObject(this,obj).
The CompountPropertyModel than takes the id of the component and
interprets it as a bean _expression_ into the underlying Object (or in case
the the CoumpoundPropertyModel wraps another model the Object from the
wrapped model).
So in your case:
==>form.setModelObject(aNew)==>CompoundPropModel.setObject(form,aNew)==>map.put(form.getId(),aNew);
There are a few solutions (and others):
1.) keep the underlying map in an instance variable und access it (in case
you do not use
detachable things).
2.) use form.getModel().setObject(null,new Map())
