You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Raoul Zander <rz...@adclear.net> on 2014/07/29 16:29:00 UTC

Possible error with IComponentInheritedModel(s) and stateful pages

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

Re: Possible error with IComponentInheritedModel(s) and stateful pages

Posted by Raoul Zander <rz...@adclear.net>.
Hi Sven,

okay, I created a jira issue + quickstart:
https://issues.apache.org/jira/browse/WICKET-5655 . Hope that helps :)

Kind regards,
rza

2014-07-29 19:53 GMT+02:00 Sven Meier <sv...@meiers.net>:

> Hi,
>
> I agree, that look bogus.
>
> WICKET-3413 tried to improve on a similar issue though:
>
>     https://issues.apache.org/jira/browse/WICKET-3413
>
> Wouldn't it be easier, just to always clear FLAG_INHERITABLE_MODEL in
> #setDefaultModel(), i.e. when a model is set explicitely?
>
> Please create a Jira issue.
>
> Regards
> Sven
>
>
>
> On 07/29/2014 05:26 PM, Raoul Zander wrote:
>
>> 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 <sv...@meiers.net>:
>>
>>  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 <sv...@meiers.net>:
>>>>
>>>>   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: users-unsubscribe@wicket.apache.org
>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>
>>>>>
>>>>>
>>>>>  ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Possible error with IComponentInheritedModel(s) and stateful pages

Posted by Sven Meier <sv...@meiers.net>.
Hi,

I agree, that look bogus.

WICKET-3413 tried to improve on a similar issue though:

     https://issues.apache.org/jira/browse/WICKET-3413

Wouldn't it be easier, just to always clear FLAG_INHERITABLE_MODEL in 
#setDefaultModel(), i.e. when a model is set explicitely?

Please create a Jira issue.

Regards
Sven


On 07/29/2014 05:26 PM, Raoul Zander wrote:
> 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 <sv...@meiers.net>:
>
>> 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 <sv...@meiers.net>:
>>>
>>>   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: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
>>>>
>>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Possible error with IComponentInheritedModel(s) and stateful pages

Posted by Raoul Zander <rz...@adclear.net>.
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 <sv...@meiers.net>:

> 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 <sv...@meiers.net>:
>>
>>  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: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Possible error with IComponentInheritedModel(s) and stateful pages

Posted by Sven Meier <sv...@meiers.net>.
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 <sv...@meiers.net>:
>
>> 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: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Possible error with IComponentInheritedModel(s) and stateful pages

Posted by Raoul Zander <rz...@adclear.net>.
In Component.setModelImpl(IModel)

- rza

2014-07-29 16:37 GMT+02:00 Sven Meier <sv...@meiers.net>:

> 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: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Possible error with IComponentInheritedModel(s) and stateful pages

Posted by Sven Meier <sv...@meiers.net>.
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: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org