Hi Pieter,
I don't use Hibernate, but db4o. The principle however might help you.
I inject my factory methods into my pages using Spring (but that is a
minor detail) and when I make a change to a domain object, I always
store the object first before reloading the page (or in this case,
rendering the ajax changes). When the page reloads, it loads the
modified object from the database. This is important to also ensure
your domain objects are persisted otherwise, they might still hang
around in wicket, but might not be stored in the db.
So you need to do something like
public void onClick(AjaxRequestTarget target){
employee. addAccount(new Account());
employeeFactory.store(employee);
...
}
Rgds,
Pieter
On Tue, Nov 10, 2009 at 9:00 PM, Pieter Degraeuwe
<[email protected]> wrote:
> Hi,
>
> I can't imagine that I'm the only one with the following situation.
>
> I have a page which edits an 'Employee'. Since I use hibernate and spring I
> use the LDM togeather with the OpenSessionInView.
> This works great (==No more LazyLoadExceptions at all...)
>
> But.... The Employee has a propertie accounts, which is a collection of
> Account objects. I'm showing these objects using a Listview.
> Now I want to add an Ajax link ('Add new account), which adds a fresh new
> Account object. I add the containing form to the AjaxRequestTarget so the
> ListView refreshes.
>
> Unfortunately, this approach never works, since my Employee is always
> reloaded from the database each reques.
>
> (I even think the same problem shows up when you do the same without ajax..)
>
> What is the best approach to deal with this?
>
> --
> Pieter Degraeuwe
> Systemworks bvba
> Belgiƫlaan 61
> 9070 Destelbergen
> GSM: +32 (0)485/68.60.85
> Email: [email protected]
> visit us at http://www.systemworks.be
>
--
Pieter Claassen
musmato.com
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]