You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by meduolis <me...@gmail.com> on 2013/02/09 14:05:16 UTC
Loadable non-detachable list model for listView
Hi, is there any way to create non-detachable objects model for list view?
I want to load actual objects from database for listview items, so I will be
able to modify them without reloading.
Let say:
If I use
as my listView model I will not be able to delete them right away like this
I will get an exception that object is detached. So if I want to delete it,
I need to reload it from DB.
Is there any way to load non-detached model object?
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Loadable-non-detachable-list-model-for-listView-tp4656216.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Loadable non-detachable list model for listView
Posted by meduolis <me...@gmail.com>.
Yes, this is what I wanted. But after I made some investigation how to apply
this OSIV filter I found that it could bring more mess then happiness :D;
Source:
http://stackoverflow.com/questions/1103363/why-is-hibernate-open-session-in-view-considered-a-bad-practice
Source how to apply:
http://www.jroller.com/cardsharp/entry/open_session_in_view_pattern;
Thanks Sven, for help.
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Loadable-non-detachable-list-model-for-listView-tp4656216p4656738.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Loadable non-detachable list model for listView
Posted by Sven Meier <sv...@meiers.net>.
You'll need to apply the OSIV pattern for that.
Sven
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Loadable-non-detachable-list-model-for-listView-tp4656216p4656734.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Loadable non-detachable list model for listView
Posted by meduolis <me...@gmail.com>.
I get same exception with your updates. Looks like I have to reload object
from database before it's deletion or delete it by id. Anyway, thanks for
help.
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Loadable-non-detachable-list-model-for-listView-tp4656216p4656733.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Loadable non-detachable list model for listView
Posted by Sven Meier <sv...@meiers.net>.
Hi,
when working with Wicket models, you should always call #getObject() or
#getModelObject() as late as possible:
ListView<ImagesGroup> imagesGroupsListView = new
ListView<ImagesGroup>("imagesGroupsListView", imagesGroupsModel) {
@Override
@Transactional
protected void populateItem(final ListItem<ImagesGroup> listItem) {
AjaxLink<String> deleteImagesGroup = new
AjaxLink<String>("deleteImagesGroup") {
@Override
public void onClick(AjaxRequestTarget target) {
// access model object as late as possible
imagesGroupService.deleteImagesGroup(listItem.getModelObject());
// force reload
imagesGroupsModel.detach();
target.add(imagesGroupsForm);
}
};
listItem.add(deleteImagesGroup);
}
};
Can you spot the difference?
Sven
On 02/24/2013 08:12 AM, meduolis wrote:
> This does not solves the issue.
>
> Heres my code:
>
>
>
>
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Loadable-non-detachable-list-model-for-listView-tp4656216p4656727.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> 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: Loadable non-detachable list model for listView
Posted by meduolis <me...@gmail.com>.
This does not solves the issue.
Heres my code:
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Loadable-non-detachable-list-model-for-listView-tp4656216p4656727.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Loadable non-detachable list model for listView
Posted by Sven Meier <sv...@meiers.net>.
You can use a model that is able to load the image object from the
database by id:
http://wicketinaction.com/2008/09/building-a-smart-entitymodel/
Either you override ListView#getListItemModel() to return such a smart
model or you use IDataProvider.
Hope this helps
Sven
On 02/09/2013 02:05 PM, meduolis wrote:
> Hi, is there any way to create non-detachable objects model for list view?
>
> I want to load actual objects from database for listview items, so I will be
> able to modify them without reloading.
>
> Let say:
>
> If I use
>
> as my listView model I will not be able to delete them right away like this
>
> I will get an exception that object is detached. So if I want to delete it,
> I need to reload it from DB.
>
> Is there any way to load non-detached model object?
>
>
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Loadable-non-detachable-list-model-for-listView-tp4656216.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> 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