Hi,
the flag is not set to true - that's the problem :)
See the method Component.setModelImpl(IModel)
especially (Line 2981 in Wicket-Core 6.16.0):
if (getFlag(FLAG_INHERITABLE_MODEL) && !(model instanceof
IComponentInheritedModel))
{
setFlag(FLAG_INHERITABLE_MODEL, false);
}
Which should probably be
if (getFlag(FLAG_INHERITABLE_MODEL) && !(model instanceof IWrapModel))
{
setFlag(FLAG_INHERITABLE_MODEL, false);
}
Regards,
rza
2014-07-29 17:09 GMT+02:00 Sven Meier <[email protected]>:
> Hi,
>
> if I look for setFlag(FLAG_INHERITABLE_MODEL, true), it is called in
> initModel() only.
>
> Please paste the relevant code or even better create a quickstart.
>
> Regards
> Sven
>
>
> On 07/29/2014 04:59 PM, Raoul Zander wrote:
>
>> In Component.setModelImpl(IModel)
>>
>> - rza
>>
>> 2014-07-29 16:37 GMT+02:00 Sven Meier <[email protected]>:
>>
>> Hi,
>>>
>>>
>>> the setModel(CompoundPropertyModel ...) actually KEEPS the
>>>>
>>> FLAG_INHERITABLE_MODEL on true
>>>
>>> where is that?
>>>
>>> Sven
>>>
>>>
>>>
>>> On 07/29/2014 04:29 PM, Raoul Zander wrote:
>>>
>>> Hi everyone,
>>>>
>>>> I think there is some kind of bug in the handling of
>>>> CompoundPropertyModel
>>>> (or any IComponentInheritedModel).
>>>>
>>>> In Component exists a Flag FLAG_INHERITABLE_MODEL - which is set to true
>>>> whenever a model is inherited from a parent, so that the model can be
>>>> nulled onDetach. Thing is: The same flag is set when a
>>>> IComponentInheritedModel is set as default model (via
>>>> setModelImpl(IModel)).
>>>>
>>>> This leads to exceptions with chained CompoundPropertyModels as in the
>>>> following scenario:
>>>>
>>>> (With correct indention and code high lighting:
>>>> http://pastebin.com/5iu0qhWw
>>>> )
>>>>
>>>> // POJOs (implements Serializable omitted)
>>>> public class Game {
>>>> private Data data;
>>>> // getters / setters
>>>> }
>>>>
>>>> public class Data {
>>>> private Value value;
>>>> // getters / setters
>>>> }
>>>>
>>>>
>>>> public class Value {
>>>> private int number;
>>>> // getters / setters
>>>> }
>>>>
>>>> // Panels
>>>> public class DataPanel extends GenericPanel<Data> {
>>>>
>>>> public DataPanel(String id) {
>>>> super(id);
>>>> }
>>>>
>>>> protected void onInitialize() {
>>>> super.onInitialize();
>>>>
>>>> setModel(new CompoundPropertyModel<Data>(getModel()));
>>>> add(new ValuePanel("value"));
>>>> }
>>>> }
>>>>
>>>> public class ValuePanel extends GenericPanel<Value> {
>>>>
>>>> public ValuePanel(String id) {
>>>> super(id);
>>>> }
>>>>
>>>> protected void onInitialize() {
>>>> super.onInitialize();
>>>>
>>>> setModel(new CompoundPropertyModel<Value>(getModel()));
>>>> add(new Label("number"));
>>>> }
>>>> }
>>>>
>>>> // and the page
>>>> public class GamePage extends WebPage {
>>>>
>>>> protected void onInitialize() {
>>>> super.onInitialize();
>>>>
>>>> setDefaultModel(new CompoundPropertyModel<Game>(new Game()));
>>>> // make Page stateful like it would happen with AJAX links and
>>>> alike
>>>> setStatelessHint(false);
>>>> add(new DataPanel("data"));
>>>> }
>>>> }
>>>>
>>>> Markup is irrelevant. The first time the page loads correct but as soon
>>>> as
>>>> you refresh the page you'll get the error "No get method defined for
>>>> class:
>>>> class Game expression: number".
>>>> Why that? Because the setModel(CompoundPropertyModel ...) actually KEEPS
>>>> the FLAG_INHERITABLE_MODEL on true so that our custom set model will be
>>>> nulled on the next detach.
>>>>
>>>> In my opinion this is a bug as FLAG_INHERITABLE_MODEL should be true if
>>>> (and only if) the current component model was inherited - and not if it
>>>> is
>>>> *inheritable*.
>>>> But on the other hand: Maybe i'm using the models the wrong way and
>>>> there's
>>>> a better way to achieve the same result (basically using
>>>> CompoundPorpertyModels on different levels of an object graph)
>>>>
>>>> Kind regards,
>>>> rza
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [email protected]
>>> For additional commands, e-mail: [email protected]
>>>
>>>
>>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>