It is pretty simple, really, just using the Facade Pattern (Gang Of Four).
If you don't actively use patterns, now would be a great time to start.
Check out these links for more info:

http://www.cs.ucsb.edu/~cappello/50/lectures/patterns/Facade.html
http://unicoi.kennesaw.edu/~jbamford/csis4650/uml/GoF_Patterns/facade.htm
http://store.yahoo.com/softpro/0-201-48567-2.html -- Refactoring, Martin
Fowler
http://c2.com/cgi/wiki

Okay, off the soap box...

Say I have a complex intake group called Account that will gather
information for both a Customer and a ShippingAddress object.  I want only
one form submittal so that the user doesn't have to go through a wizard, but
I also want separate objects because Addresses are stored separately.  Below
is a rough example of the Adaptor class and Intake group declaration.

public class IntakeCustomerAccountFacade implements Retrievable
{
        private Customer customer = new Customer();
        private ShippingAddress shipping = new ShippingAddress();

        public IntakeCustomerAccountFacade ()
        {
        }

        public IntakeCustomerAccountFacade (Customer cust,ShippingAddress ship)
        {
                customer = cust;
                shipping = ship;
        }

        <...get/SetQueryKey() methods...>

        public void setName(String arg)
        {
                customer.setName(arg);
        }

        public String getName()
        {
                shipping.getName()
        }

        public void setShippingStreetAddress(String arg)
        {
                shipping.setStreetAddress(arg);
        }

        public String getShippingStreetAddress()
        {
                shipping.getStreetAddress()
        }
}

<group mapToObject="com.mycompany.om.IntakeCustomerAccountFacade">
        <field name="Name" key="name" type="String"/>
        <field name="ShippingStreetAddress" key="shstaddr" type="String"/>
</group>

I hope this helps,

Chris

-----Original Message-----
From: Marc Lustig [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, February 19, 2003 12:18 PM
To: Turbine Users List
Subject: AW: intake: mapping the group against 2 objects possible?


Chris, I'd be very much interested to have a look on how you modeled this.
I'm sure others would benefit as well. Could you contribute a howto that
explains the solution roughly ?


> -----Ursprungliche Nachricht-----
> Von: Chris K Chew [mailto:[EMAIL PROTECTED]]
> Gesendet: Mittwoch, 19. Februar 2003 18:10
> An: Turbine Users List
> Betreff: RE: intake: mapping the group against 2 objects possible?
>
>
> We usually write a facade/adaptor class for complex Intake
> groups.  There is
> something like an init() method which loads the constituent base objects,
> and the get/set methods simply pass the call on to the proper constituent.
>
> It works well for us and simplifies the screen/action classes.
>
> Chris
>
> -----Original Message-----
> From: Marc Lustig [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, February 19, 2003 4:13 AM
> To: Turbine Users List
> Subject: AW: intake: mapping the group against 2 objects possible?
>
>
>
> > -----Ursprungliche Nachricht-----
> > Von: Scott Eade [mailto:[EMAIL PROTECTED]]
> > Gesendet: Dienstag, 18. Februar 2003 23:04
> > An: turbine-user
> > Betreff: Re: intake: mapping the group against 2 objects possible?
> >
> >
> > On 19/02/2003 8:57 AM, "Marc Lustig" <[EMAIL PROTECTED]> wrote:
> >
> > > This is the standard code to populate the group with the data
> > from a bo, so
> > > that the form-data displays the existing values:
> > >
> > > #set($group=$intake.SomeGroup.mapTo($bo))
> > >
> > > Q: is it possible to map the group against two different objects?
> > >
> > > What's the proper way to do that?
> >
> > Have you tried it?  I suspect it will just work.
>
> It didn't really.
> I solved this by handling with two different groups, one for each of the
> BO's. This required to create another Intake group and setProperties() in
> the action for both groups. That's not a bad solution.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>


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


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

Reply via email to