Re: Loadable-detachable collections?
That worked a charm Nino, thanks. I can see now that I was previously setting a raw SystemUser object as the ListView model as opposed to the wrapped LDM object. I'll still check out the DataView as well. Thanks all for your replies. Nino.Martinez wrote: > > You are not chaining... > > This is how: > > new PropertyModel(userModel,"contacts") > > > -- View this message in context: http://www.nabble.com/Loadable-detachable-collections--tp19685949p19693433.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]
Re: Loadable-detachable collections?
You are not chaining... This is how: new PropertyModel(userModel,"contacts") Neil McT wrote: Sure. Originally I had it set up like (note that userModel is a LDM which wraps a SystemUser. SystemUser contains a collection of Contact objects). final WebMarkupContainer listContainer = new WebMarkupContainer("listContainer"); ListView displayList = new ListView("contactsList", userModel.getObject().getContacts()){ @Override protected void populateItem(final ListItem item) { Contact contact = (Contact)item.getModelObject(); item.add(new Label("contactName", contact.getName())); etc etc This was producing the original error AbstractPersistentCollection.owner [class=com.myapp.domain.SystemUser] <- field that is not serializable I then tried. final WebMarkupContainer listContainer = new WebMarkupContainer("listContainer"); ListView displayList = new ListView( "contactsList", new PropertyModel(userModel.getObject(), "contacts")){ @Override protected void populateItem(final ListItem item) { item.add(new Label("contactName", ((Contact)item.getModelObject()).getName())); etc etc And was getting private java.lang.Object org.apache.wicket.model.AbstractPropertyModel.target [class=com.pyso.domain.SystemUser] <- field that is not serializable I'm assuming, from the PropertyModel. jwcarman wrote: How about sharing some code with us as to how you're setting up your models? -- -Wicket for love Nino Martinez Wael Java Specialist @ Jayway DK http://www.jayway.dk +45 2936 7684 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Loadable-detachable collections?
And checkout the AjaxFallbackDefaultDataTable while your at it.. It's really nice too. Neil McT wrote: I wasn't getting the error from the main LDM but from the underlying collection (and its reference back to 'owner'). I need to display all collections elements in this instance but maybe on other pages, only a subset. Thanks both for your replies. I'm probably going to have a look at DataView. jwcarman wrote: Yes, perhaps I wasn't clear enough. But, Martijn is correct. A DataView (which uses a DataProvider) might be a better choice in your situation (unless you have to load the entity to display other parts of your page anyway). Are you always showing all members of the nested collection? -- -Wicket for love Nino Martinez Wael Java Specialist @ Jayway DK http://www.jayway.dk +45 2936 7684 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Loadable-detachable collections?
Sure. Originally I had it set up like (note that userModel is a LDM which wraps a SystemUser. SystemUser contains a collection of Contact objects). final WebMarkupContainer listContainer = new WebMarkupContainer("listContainer"); ListView displayList = new ListView("contactsList", userModel.getObject().getContacts()){ @Override protected void populateItem(final ListItem item) { Contact contact = (Contact)item.getModelObject(); item.add(new Label("contactName", contact.getName())); etc etc This was producing the original error AbstractPersistentCollection.owner [class=com.myapp.domain.SystemUser] <- field that is not serializable I then tried. final WebMarkupContainer listContainer = new WebMarkupContainer("listContainer"); ListView displayList = new ListView( "contactsList", new PropertyModel(userModel.getObject(), "contacts")){ @Override protected void populateItem(final ListItem item) { item.add(new Label("contactName", ((Contact)item.getModelObject()).getName())); etc etc And was getting private java.lang.Object org.apache.wicket.model.AbstractPropertyModel.target [class=com.pyso.domain.SystemUser] <- field that is not serializable I'm assuming, from the PropertyModel. jwcarman wrote: > > How about sharing some code with us as to how you're setting up your > models? > > -- View this message in context: http://www.nabble.com/Loadable-detachable-collections--tp19685949p19693132.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]
Re: Loadable-detachable collections?
How about sharing some code with us as to how you're setting up your models? On Fri, Sep 26, 2008 at 12:48 PM, Neil McT <[EMAIL PROTECTED]> wrote: > > I wasn't getting the error from the main LDM but from the underlying > collection (and its reference back to 'owner'). > > I need to display all collections elements in this instance but maybe on > other pages, only a subset. > > Thanks both for your replies. I'm probably going to have a look at DataView. > > > > > jwcarman wrote: >> >> Yes, perhaps I wasn't clear enough. But, Martijn is correct. A >> DataView (which uses a DataProvider) might be a better choice in your >> situation (unless you have to load the entity to display other parts >> of your page anyway). Are you always showing all members of the >> nested collection? >> >> > > -- > View this message in context: > http://www.nabble.com/Loadable-detachable-collections--tp19685949p19692314.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]
Re: Loadable-detachable collections?
I wasn't getting the error from the main LDM but from the underlying collection (and its reference back to 'owner'). I need to display all collections elements in this instance but maybe on other pages, only a subset. Thanks both for your replies. I'm probably going to have a look at DataView. jwcarman wrote: > > Yes, perhaps I wasn't clear enough. But, Martijn is correct. A > DataView (which uses a DataProvider) might be a better choice in your > situation (unless you have to load the entity to display other parts > of your page anyway). Are you always showing all members of the > nested collection? > > -- View this message in context: http://www.nabble.com/Loadable-detachable-collections--tp19685949p19692314.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]
Re: Loadable-detachable collections?
Yes, perhaps I wasn't clear enough. But, Martijn is correct. A DataView (which uses a DataProvider) might be a better choice in your situation (unless you have to load the entity to display other parts of your page anyway). Are you always showing all members of the nested collection? On Fri, Sep 26, 2008 at 12:25 PM, Martijn Dashorst <[EMAIL PROTECTED]> wrote: > James suggested 'model chaining', where you nest the LDM inside > property models. In your case I'd suggest using a DataView instead, as > it is easier to work with when using LDM's and data coming from > databases. > > If you still want to use ListView, you'll have to override > newListItemModel (iirc) and let that one return a LDM for the item in > the list. > > Martijn > > On Fri, Sep 26, 2008 at 6:11 PM, Neil McT <[EMAIL PROTECTED]> wrote: >> >> Yeah, I originally had that - a LDM as the main model and the ListView model >> based on that. I've also tried a couple of variations of this but I still >> get the Serialization errors. I think maybe I'm not following you exactly. >> >> As far as I can see the ListView needs a collection as a model (the >> collection of Contacts) and, no matter how I configure this model, it will >> still point to non-serializable objects (either the 'owner' property of the >> AbstractPersistentCollection or perhaps the Contacts themselves). So does >> the collection itself need to be Loadable / Detachable? >> >> Thanks. >> >> >> >> >> jwcarman wrote: >>> >>> I usually use a LDM for the main object (which has the collection >>> property) and have the model for the collection based upon that >>> (perhaps a PropertyModel?). >>> >>> >> >> -- >> View this message in context: >> http://www.nabble.com/Loadable-detachable-collections--tp19685949p19691650.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] >> >> > > > > -- > Become a Wicket expert, learn from the best: http://wicketinaction.com > Apache Wicket 1.3.4 is released > Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3. > > - > 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]
Re: Loadable-detachable collections?
The main LDM shouldn't get you serialization errors, because you're not serializing the "entity" (just the key perhaps and a proxied reference to your dao/repository). On Fri, Sep 26, 2008 at 12:11 PM, Neil McT <[EMAIL PROTECTED]> wrote: > > Yeah, I originally had that - a LDM as the main model and the ListView model > based on that. I've also tried a couple of variations of this but I still > get the Serialization errors. I think maybe I'm not following you exactly. > > As far as I can see the ListView needs a collection as a model (the > collection of Contacts) and, no matter how I configure this model, it will > still point to non-serializable objects (either the 'owner' property of the > AbstractPersistentCollection or perhaps the Contacts themselves). So does > the collection itself need to be Loadable / Detachable? > > Thanks. > > > > > jwcarman wrote: >> >> I usually use a LDM for the main object (which has the collection >> property) and have the model for the collection based upon that >> (perhaps a PropertyModel?). >> >> > > -- > View this message in context: > http://www.nabble.com/Loadable-detachable-collections--tp19685949p19691650.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]
Re: Loadable-detachable collections?
James suggested 'model chaining', where you nest the LDM inside property models. In your case I'd suggest using a DataView instead, as it is easier to work with when using LDM's and data coming from databases. If you still want to use ListView, you'll have to override newListItemModel (iirc) and let that one return a LDM for the item in the list. Martijn On Fri, Sep 26, 2008 at 6:11 PM, Neil McT <[EMAIL PROTECTED]> wrote: > > Yeah, I originally had that - a LDM as the main model and the ListView model > based on that. I've also tried a couple of variations of this but I still > get the Serialization errors. I think maybe I'm not following you exactly. > > As far as I can see the ListView needs a collection as a model (the > collection of Contacts) and, no matter how I configure this model, it will > still point to non-serializable objects (either the 'owner' property of the > AbstractPersistentCollection or perhaps the Contacts themselves). So does > the collection itself need to be Loadable / Detachable? > > Thanks. > > > > > jwcarman wrote: >> >> I usually use a LDM for the main object (which has the collection >> property) and have the model for the collection based upon that >> (perhaps a PropertyModel?). >> >> > > -- > View this message in context: > http://www.nabble.com/Loadable-detachable-collections--tp19685949p19691650.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] > > -- Become a Wicket expert, learn from the best: http://wicketinaction.com Apache Wicket 1.3.4 is released Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Loadable-detachable collections?
Yeah, I originally had that - a LDM as the main model and the ListView model based on that. I've also tried a couple of variations of this but I still get the Serialization errors. I think maybe I'm not following you exactly. As far as I can see the ListView needs a collection as a model (the collection of Contacts) and, no matter how I configure this model, it will still point to non-serializable objects (either the 'owner' property of the AbstractPersistentCollection or perhaps the Contacts themselves). So does the collection itself need to be Loadable / Detachable? Thanks. jwcarman wrote: > > I usually use a LDM for the main object (which has the collection > property) and have the model for the collection based upon that > (perhaps a PropertyModel?). > > -- View this message in context: http://www.nabble.com/Loadable-detachable-collections--tp19685949p19691650.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]
Re: Loadable-detachable collections?
I usually use a LDM for the main object (which has the collection property) and have the model for the collection based upon that (perhaps a PropertyModel?). On Fri, Sep 26, 2008 at 6:34 AM, Neil McT <[EMAIL PROTECTED]> wrote: > > I'm using LoadableDetachableModels to minimise the serialized session state > of my app. However, there is one place where I am still seeing > WicketNotSerializableException and that is where I use a hibernate > collection as a components model. > > I have a SystemUser class which contains a List of Contact objects - both > are hibernate entities. This collection of Contact objects form the model > for a ListView but throws the WicketNotSerializableException as follows... > > [snip] > private java.lang.Object > org.hibernate.collection.AbstractPersistentCollection.owner > [class=com.myapp.domain.SystemUser] <- field that is not serializable > > > So it seems that the underlying hibernate collection has a field 'owner' (in > this case the SystemUser) which wicket is trying to serialize. I'm not sure > of the best way to make this owner object (and the collection objects > themselves, probably) LoadableDetachableObjects. > > Any ideas? > > Thanks - Neil. > -- > View this message in context: > http://www.nabble.com/Loadable-detachable-collections--tp19685949p19685949.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]
Loadable-detachable collections?
I'm using LoadableDetachableModels to minimise the serialized session state of my app. However, there is one place where I am still seeing WicketNotSerializableException and that is where I use a hibernate collection as a components model. I have a SystemUser class which contains a List of Contact objects - both are hibernate entities. This collection of Contact objects form the model for a ListView but throws the WicketNotSerializableException as follows... [snip] private java.lang.Object org.hibernate.collection.AbstractPersistentCollection.owner [class=com.myapp.domain.SystemUser] <- field that is not serializable So it seems that the underlying hibernate collection has a field 'owner' (in this case the SystemUser) which wicket is trying to serialize. I'm not sure of the best way to make this owner object (and the collection objects themselves, probably) LoadableDetachableObjects. Any ideas? Thanks - Neil. -- View this message in context: http://www.nabble.com/Loadable-detachable-collections--tp19685949p19685949.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]