Hi Johannes,

(and greetings, dear former colleague 😉)

As I said - it is not about Components detaching Models. At the end of the 
render cycle, the ListView detaches its Model, this is default & fine.

My point is, that the detaching of Models is not consistently implemented, if 
you take a look at ListItemModel vs. the implementations produced by (e.g.) 
IModel.map(...) or LambdaModel.of(IModel<X> target,...).
The ListItemModel does not care about its dependencies, the latter do - which 
is correct in my humble opinion.

My very specific use case would be too long to post here, but I have a ListView 
A which renders a Component B, which is implemented in a separate class. 
Component B does not know anything about its parent (ListView) Component or the 
ListItemModel, which is passed as default model, as it is a reusable Component. 
But this example is not really important here. I just made me stumble over the 
inconsistent implementation (imho 😉) described in the paragraph above.
Using events would be possible to work around the problem but it would feel 
like a hack. I'd rather prefer a consistent implementation of detach().

Best regards,
Hannes
________________________________
From: Johannes Renoth <johan...@renoth.dev>
Sent: Thursday, July 11, 2024 14:01
To: users@wicket.apache.org <users@wicket.apache.org>
Subject: Re: ListItemModel is not detaching List-model

Hi Hannes,

Shouldn't the detaching of the ListModel be handled by the ListView
itself? Why would you detach the complete ListModel from inside a
component in the ListView? You could always send an event to the parent
of the ListItem however ...

Greetings,

Johannes

On 11/07/2024 13:44, Hannes Becker wrote:
> Hi!
>
> Thanks for your feedback.
>
> Maybe I need to elaborate my point a little bit more. It's not about 
> Components detaching Models but about the detaching-responsibility of 
> dependent models.
>
> A detach on a (child) Model, which depends on another (parent) Model normally 
> detaches also the parent Model. The most "prominent" example is the default 
> implementation of IModel.map(...).
>
> In opposition to that, ListItemModel.detach() has a (default) 
> noop-implementation and I am wondering why it is not implemented as the 
> following:
>
> ----
> @Override
> public void detach()
> {
>       listView.getModel().detach();
> }
> ----
>
> This is actually a problem for me, because I have a LoadableDetachableModel, 
> which is the "parent" Model for the ListView. This LoadableDetachableModel 
> needs to be detached but I don't have a reference to the 
> LoadableDetachableModel in the Component which is rendered inside the 
> ListView. If detach would be implemented in the way I proposed (and how it is 
> implemented in IModel.map(...)), it would just work.
> Thus, I suggest do implement detach as described above in ListItemModel.
>
> Best regards,
> Hannes
>
> ________________________________
> From: Martin Terra <martin.te...@koodaripalvelut.com>
> Sent: Wednesday, July 10, 2024 12:57
> To: users@wicket.apache.org <users@wicket.apache.org>
> Subject: Re: ListItemModel is not detaching List-model
>
> Normally it's the other way, a component detaches it's model.
>
> The ListItemModel isn't really holding any data, it is relying on the
> actual model held by listView.
>
> **
> Martin
>
> ke 10. heinäk. 2024 klo 13.53 Hannes Becker (hannes.bec...@proxora.com)
> kirjoitti:
>
>> Hi!
>>
>> I am wondering why org.apache.wicket.markup.html.list.ListItemModel is not
>> detaching the ListView's model. Feels to me like a bug...or is there an
>> explanation?
>>
>> Thanks for your help and best regards
>> Hannes
>>
>>

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

Reply via email to