You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Štefan Šimík <st...@gmail.com> on 2015/11/28 21:10:26 UTC

Passing ListItemModel to another model

PROBLEM:
When ListItemModel is wrapped into CompoundPropertyModel (that is used as
default model of Form),
then Form model-object is never updated -> so old data are saved, without
any changes.


EXAMPLE OF PROBLEM:
Example of problem: (data in form object are NOT updated after from
submission)

    ListItemModel listItemModel = ...coming from ListView
    CompoundPropertyModel<Category> compoundModel = new
CompoundPropertyModel<Category>(listItemModel);


HOW PROBLEM WAS FIXED:
Fix was to extract model-object from ListItemModel and rewrap it into
CompoundPropertyModel.

    ListItemModel listItemModel = ...coming from ListView
    CompoundPropertyModel<Category> compoundModel = new
CompoundPropertyModel<Category>(listItemModel.getObject());


QUESTION
I suppose, that core of the problem is, that ListItemModel does not
implement IChainingModel, so it cannot be passed to another model... but I
am not sure, if I understand that correctly and identified the real core
problem.

Could you please confirm this, or provide some alternative explanation, why
I cannot ListItemModel to the CompoundPropertyModel (into its constructor) ?


Thank you for your help and explanation.

Re: Passing ListItemModel to another model

Posted by Štefan Šimík <st...@gmail.com>.
Thank you Sven for help.

I created quickstart and found out a problem.
What you said is true - the problem is really not in CompoundPropertyModel
or in nesting of ListItemModel.

REAL PROBLEM WAS:
I was mistakenly passing Hibernate entities directly between pages -
without proper encapsulating them into LoadableDetachableModel.

As I was using hibernate merge() function to both save/update server data
-> that caused, that old data was merged and my form magically worked.
when de/serialized hibernate-entities already had assigned database ID.
That completely distracted me from looking for problem on server-side
and I mistakenly looked it on client side instead.

Doing isolated quickstart for myself will be the 1st thing I try next time
;)
Anyway, thank you, for pointing me to the right direction!

On Sat, Nov 28, 2015 at 9:47 PM, Sven Meier <sv...@meiers.net> wrote:

> Hi,
>
> > I suppose, that core of the problem is, that ListItemModel does not
> > implement IChainingModel, so it cannot be passed to another model...
>
> CompoundPropertyModel does not care of the actual model implementation, it
> should work fine with any target model.
>
> Actually Wicket provides PropertyListView, which exactly wraps a
> ListItemModel in a CompoundPropertyModel.
>
> Please create a quickstart so we can see the cause of your problem.
>
> Have fun
> Sven
>
>
>
>
> On 28.11.2015 21:10, Štefan Šimík wrote:
>
>> PROBLEM:
>> When ListItemModel is wrapped into CompoundPropertyModel (that is used as
>> default model of Form),
>> then Form model-object is never updated -> so old data are saved, without
>> any changes.
>>
>>
>> EXAMPLE OF PROBLEM:
>> Example of problem: (data in form object are NOT updated after from
>> submission)
>>
>>      ListItemModel listItemModel = ...coming from ListView
>>      CompoundPropertyModel<Category> compoundModel = new
>> CompoundPropertyModel<Category>(listItemModel);
>>
>>
>> HOW PROBLEM WAS FIXED:
>> Fix was to extract model-object from ListItemModel and rewrap it into
>> CompoundPropertyModel.
>>
>>      ListItemModel listItemModel = ...coming from ListView
>>      CompoundPropertyModel<Category> compoundModel = new
>> CompoundPropertyModel<Category>(listItemModel.getObject());
>>
>>
>> QUESTION
>> I suppose, that core of the problem is, that ListItemModel does not
>> implement IChainingModel, so it cannot be passed to another model... but I
>> am not sure, if I understand that correctly and identified the real core
>> problem.
>>
>> Could you please confirm this, or provide some alternative explanation,
>> why
>> I cannot ListItemModel to the CompoundPropertyModel (into its
>> constructor) ?
>>
>>
>> Thank you for your help and explanation.
>>
>>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Passing ListItemModel to another model

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

 > I suppose, that core of the problem is, that ListItemModel does not
 > implement IChainingModel, so it cannot be passed to another model...

CompoundPropertyModel does not care of the actual model implementation, 
it should work fine with any target model.

Actually Wicket provides PropertyListView, which exactly wraps a 
ListItemModel in a CompoundPropertyModel.

Please create a quickstart so we can see the cause of your problem.

Have fun
Sven



On 28.11.2015 21:10, Štefan Šimík wrote:
> PROBLEM:
> When ListItemModel is wrapped into CompoundPropertyModel (that is used as
> default model of Form),
> then Form model-object is never updated -> so old data are saved, without
> any changes.
>
>
> EXAMPLE OF PROBLEM:
> Example of problem: (data in form object are NOT updated after from
> submission)
>
>      ListItemModel listItemModel = ...coming from ListView
>      CompoundPropertyModel<Category> compoundModel = new
> CompoundPropertyModel<Category>(listItemModel);
>
>
> HOW PROBLEM WAS FIXED:
> Fix was to extract model-object from ListItemModel and rewrap it into
> CompoundPropertyModel.
>
>      ListItemModel listItemModel = ...coming from ListView
>      CompoundPropertyModel<Category> compoundModel = new
> CompoundPropertyModel<Category>(listItemModel.getObject());
>
>
> QUESTION
> I suppose, that core of the problem is, that ListItemModel does not
> implement IChainingModel, so it cannot be passed to another model... but I
> am not sure, if I understand that correctly and identified the real core
> problem.
>
> Could you please confirm this, or provide some alternative explanation, why
> I cannot ListItemModel to the CompoundPropertyModel (into its constructor) ?
>
>
> Thank you for your help and explanation.
>

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