Thanks for your reply. In some situations your solution might be sufficient,
but in my situation I'm affraid not...

I cannot commit an empty Account in the db due constraint reasons. And, I
actually only want to save the Employee in the database when the user
presses the ' Save' button, not when he is adding/ modifying some Accounts.
(So, in other words, the user can always 'Cancel' his actions...



On Tue, Nov 10, 2009 at 9:16 PM, pieter claassen
<pieter.claas...@gmail.com>wrote:

> 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
> <pieter.degrae...@systemworks.be> 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: pieter.degrae...@systemworks.be
> > visit us at http://www.systemworks.be
> >
>
>
>
> --
> Pieter Claassen
> musmato.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>


-- 
Pieter Degraeuwe
Systemworks bvba
Belgiƫlaan 61
9070 Destelbergen
GSM: +32 (0)485/68.60.85
Email: pieter.degrae...@systemworks.be
visit us at http://www.systemworks.be

Reply via email to