the other constructor i presume is getting a persistent entity? so
hibernate/jpa will flush state back to db at the end of request, thats
why that works.

-igor


On Feb 9, 2008 11:08 AM, Martijn Lindhout <[EMAIL PROTECTED]> wrote:
> ok, thanx, that seems to work.
>
> And what about the other constructor, when editing an existing entity?
>
> 2008/2/9, Igor Vaynberg <[EMAIL PROTECTED]>:
>
> >
> > setModel(new CompoundPropertyModel(new LoadableDetachableModel(){
> >
> > ^ that is bad because ldm is cleared between requests, thats why its
> > called loadable
> >
> > just do this
> >
> > setModel(new CPM(new Employee()));
> >
> > -igor
> >
> >
> > On Feb 9, 2008 10:45 AM, Martijn Lindhout <[EMAIL PROTECTED]>
> > wrote:
> > > Hi,
> > >
> > > I have a page, with those two constructors, the first for editing a new
> > > employee, the second for editing an existing.
> > >
> > >     public EditEmployee() {
> > >         setModel(new CompoundPropertyModel(new
> > LoadableDetachableModel(){
> > >             protected Object load() {
> > >                 return new Employee();
> > >             }
> > >         }));
> > >         init();
> > >     }
> > >
> > >     public EditEmployee(final Long id) {
> > >         setModel(new CompoundPropertyModel(new
> > LoadableDetachableModel(){
> > >             protected Object load() {
> > >                 return empRepository.getEmployee(id);
> > >             }
> > >         }));
> > >         init();
> > >     }
> > >
> > > Because the Employee info is relatively much, I separate it in two
> > panels in
> > > a tabpanel. The hierarchy is: Page <- Form <- TabbedPanel <- several
> > Panels
> > > The problem is, that when I enter the formfields on the panels, they got
> > > valided, but then a new Employee instance is created, and the
> > FormComponent
> > > values are not copied to the newly instantiated Employee. They're null.
> > >
> > > I did some tests and it appears that on each panel switch, the
> > Model.load is
> > > called, and a new Employee is returned.
> > >
> > > What's going wrong here....
> > > --
> > > Martijn Lindhout
> > > JointEffort IT Services
> > > http://www.jointeffort.nl
> > > [EMAIL PROTECTED]
> > > +31 (0)6 18 47 25 29
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
>
>
> --
>
> Martijn Lindhout
> JointEffort IT Services
> http://www.jointeffort.nl
> [EMAIL PROTECTED]
> +31 (0)6 18 47 25 29
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to