Put your object into user's session, just like a shopping chart. :-)

-----Original Message-----
From: Benjamin Ernst [mailto:[EMAIL PROTECTED]
Sent: Monday, December 08, 2008 10:06 AM
To: [email protected]
Subject: LoadableDetachableModel in Listview


Hi everybody,

I have a little Problem with LDMs:

I have a page with a ListView and for each item in the ListView the user can
open a modalWindow to edit the item.

My Problem is, that I don't want to persist the item to the DB from the
modalWindow. Only after the User confirms the changes in the page with the
ListView, all these changes for all items from the ListView should be
persisted. Or the User presses "abort" and nothing is persisted.

When I use LDMs changes that are made in the modalWindow are never shown in
the ListView, because the models are detached.

I could use normal Models or the actual Objects for this, but then I might
run into lazy-initialization-problems.

Has anybody a solution for this problem, or is this simply not possible in
this way?

Thanks in advance,

Benjamin

-------------------------------------------------------------------

My Code looks like this:

ListView<Account> accountListView = new ListView<Account>("accountList",
accountList)
        {
            @Override
            protected void populateItem(ListItem<Account> item) {
                DetachableEntityModel<Account> account = new
DetachableEntityModel<Account>(item.getModelObject());

                item.add(new Label("accountName", new
PropertyModel<String>(account, "name")));
                item.add(new Label("accountNumber", new
PropertyModel<String>(account, "number")));

                item.add(new AjaxLink<Account>("edit", account)
                {
                    @Override
                    public void onClick(AjaxRequestTarget target) {
                        modalWindow.showPage(target, new
AccountEditPage(modalWindow, this.getModel()));
                    }
                });
            }
        };
        cont.add(accountListView);

        AjaxLink save = new AjaxLink("saveAccounts")
        {
            @Override
            public void onClick(AjaxRequestTarget target) {
                User user = userModel.getObject();
                user.getAccounts().clear();
                user.getAccounts().addAll(accountList);

                ServiceLocator.instance().getUserService().saveUser(user);
            }
        };
***************************************************************************************************
"Atenção: Esta mensagem foi enviada para uso exclusivo do(s) destinatários(s) 
acima identificado(s),
podendo conter informações e/ou documentos confidencias/privilegiados e seu 
sigilo é protegido por 
lei. Caso você tenha recebido por engano, por favor, informe o remetente e 
apague-a de seu sistema.
Notificamos que é proibido por lei a sua retenção, disseminação, distribuição, 
cópia ou uso sem 
expressa autorização do remetente. Opiniões pessoais do remetente não refletem, 
necessariamente, 
o ponto de vista da CETIP, o qual é divulgado somente por pessoas autorizadas."


"Warning: This message was sent for exclusive use of the addressees above 
identified, possibly 
containing information and or privileged/confidential documents whose content 
is protected by law. 
In case you have mistakenly received it, please notify the sender and delete it 
from your system. 
Be noticed that the law forbids the retention, dissemination, distribution, 
copy or use without 
express authorization from the sender. Personal opinions of the sender do not 
necessarily reflect 
CETIP's point of view, which is only divulged by authorized personnel."
***************************************************************************************************

Reply via email to