The order has one or more order mementos (pre/post editing) and each
order memento has a collection of orderline mementos.  The mementos
are completely opaque, and only the Order & OrderLine are able to
inspect them and extract their content -- perhaps by implementing them
a static inner classes with private mutators.

On Feb 11, 2008 10:36 AM, Martijn Lindhout <[EMAIL PROTECTED]> wrote:
> sounds interesting. Can you explain a bit more? How does this work for
> example in an Order-OrderLine situation where you edit an existing order by
> adding and removing orderlines and finally do a commit or rollback?
>
> 2008/2/11, Scott Swank <[EMAIL PROTECTED]>:
>
> >
> > I suggest using the GoF memento pattern here.  You keep your changes
> > in one or more mementos, which can be kept in the session.  Then you
> > push the changes back to the domain model when you are happy with
> > them.  We use this approach for modifying hotel reservations --
> > particularly because we need to see the price before the change as
> > well as with the change to generate e-mails, faxes, etc.
> >
> >
> > On Feb 11, 2008 10:06 AM, Martijn Lindhout <[EMAIL PROTECTED]>
> > wrote:
> > > I agree that it is *easier*, but I got bored by duplicating my domain
> > model
> > > in a DTO like structure. And that's cumbersome.
> > > I saw this hapening in several projects, and in the end we had two
> > almost
> > > equals object structures, one with rich behavior, and one with just data
> > and
> > > structure.
> > >
> > > that's sad.... or not?
> > >
> > >
> > > 2008/2/11, Igor Vaynberg <[EMAIL PROTECTED]>:
> > > >
> > > > well, you will have to disconnect the hibernate session, and store it
> > > > in the http session - or some other place. then your model would have
> > > > to reconnect the session and pull the entity out of it. its much
> > > > easier to create a bean imho.
> > > >
> > > > -igor
> > > >
> > > >
> > > > On Feb 11, 2008 12:13 AM, Martijn Lindhout <[EMAIL PROTECTED]>
> > > > wrote:
> > > > > because I use the domain objects directly,. without any DTO's, I
> > have to
> > > > use
> > > > > the long conversation pattern. That means I have to store the domain
> > > > object
> > > > > somewhere in the session and let the loadabledetachable model
> > retrieve
> > > > it
> > > > > from there?
> > > > >
> > > > > 2008/2/11, Igor Vaynberg <[EMAIL PROTECTED]>:
> > > > >
> > > > > >
> > > > > > then you have to use a bean, and on confirm apply changes from the
> > > > > > bean to the persistent entity. the only other alternative i know
> > of is
> > > > > > to use the long conversation pattern which i am not really a fan
> > of.
> > > > > >
> > > > > > -igor
> > > > > >
> > > > > >
> > > > > > On Feb 10, 2008 11:25 PM, Martijn Lindhout <
> > [EMAIL PROTECTED]>
> > > > > > wrote:
> > > > > > > ok, that makes sense.
> > > > > > >
> > > > > > > But what if I have a Hibernate persisted entity that I want to
> > edit
> > > > in
> > > > > > > multiple actions? Say I have an order with orderlines, and I
> > want to
> > > > add
> > > > > > and
> > > > > > > remove them at will, and in the end save or rollback all the
> > > > changes? I
> > > > > > > don't want the intermediate add and removes propagate directly
> > to
> > > > the
> > > > > > > database, only at 'confirm'.
> > > > > > >
> > > > > > >
> > > > > > > 2008/2/9, Igor Vaynberg <[EMAIL PROTECTED]>:
> > > > > > > >
> > > > > > > > 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]
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > --
> > > > > > > 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]
> > > >
> > > >
> > >
> > >
> > > --
> > >
> > > Martijn Lindhout
> > > JointEffort IT Services
> > > http://www.jointeffort.nl
> > > [EMAIL PROTECTED]
> > > +31 (0)6 18 47 25 29
> > >
> >
> >
> >
> > --
> > Scott Swank
> > reformed mathematician
> >
> > ---------------------------------------------------------------------
> > 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
>



-- 
Scott Swank
reformed mathematician

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

Reply via email to