On Thu, May 8, 2008 at 1:56 PM, Mathias P.W Nilsson
<[EMAIL PROTECTED]> wrote:
>
>
> add( new ListView( "myId" , detachedModel ){
> public void populateItem( ListItem item) {
> final Category category = (Category) item.getModelObject();
>
> item.add( new Link( "link" ){
> public void onClick(){
> setResponsePage( new CategoryPage( category ) );
^^^^^---------- this is bad. now your anonymous link component is
holding onto a detached category object, so if in categorypage's
constructor you try to access a lazy collection you will get an
exception. the proper thing to do here is to:
final Category category = (Category) item.getModelObject();
final IModel cat=new HibernateEntityModel(category);
item.add(new Link("link", cat){ setResponsePage(new CategoryPage(getModel()); }
the idea is to pass a lookup(a model) rather then the entity itself.
this way you are never holding onto the entity outside of a hibernate
session.
-igor
> }
> } );
> }
> });
>
> I hope this is right. This is obviously from the top of my head. My question
> is.
> When In my CategoryPage after a user has clicked the link in the list item
> is the Category that I got
> from a detached model detached? Or is it a hibernate proxy? If so, how can I
> get it detached all the way?
>
>
> Igor wrote something about a detached DataProvider. Do I need to use
> DataProvider to get detached hibernate pojos? I would really want to know
> how to do this. Right now, I'm in spagetti code with DAOS that throws
> LazyLoading exceptions and Wicket pages that does the same.
>
>
> --
> View this message in context:
> http://www.nabble.com/Detached-models-tp17136199p17136199.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> 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]