Are there other uses of the converted domain objects besides the
presentation layer?  I am wondering if it's "good practice" to tie in
Tapestry for this.  Can Type A and Type B both implement a common
interface?  Then you could have the presentation layer work on that
interface.

If a common interface was not available, and if the destination object
does not have to be backed up by the source object, a static or
singleton method that ingests Type A and outputs Type B would be my
first choice.


On 6/13/07, Ben Tomasini <[EMAIL PROTECTED]> wrote:
Thank you.

Is there native support for lists of different types?  Will the TypeCoercer
take a List<TypeA> and create a List<TypeB> if that is what is
requested?  If so, how are generic lists handled?  Does the
TypeCoercer inspect the first element for its type?

Ben


On 6/13/07, Davor Hrg <[EMAIL PROTECTED]> wrote:
>
> You need TypeCoercer,
> you can inject it where needed, and use it..
> ina a page:
> @Inject    private TypeCoercer typeCoercer
>
> in a method, or service constructor:
> public myMethod(@Inject TypeCoercer typeCoercer){....}
>
> you then use it like this:
> SomeClass destination = typeCoercer.coerce(source, SomeClass.class);
>
>
>
> to contribute your own CoercionTuple add following to your module:
>
> public static void contributeTypeCoercer(Configuration<CoercionTuple>
> configuration){.....}
>
> for more read following,
> http://tapestry.apache.org/tapestry5/tapestry-core/guide/coercion.html
> and go through tapestry-ioc guide to get to know the IOC part of the
> framework,
> and to get more familiar with creating services and dependancy injection.
>
>
> Davor Hrg
>
>
>
>
> On 6/13/07, Ben Tomasini <[EMAIL PROTECTED]> wrote:
> >
> > I have a simple requirement to tranlsate a list of type A to a list of
> > type
> > B
> >
> > I have a simple service interface to do this:
> >
> > List translate(List list)
> >
> > It does a 1:1 translation on the source list, mapping properties to the
> > new
> > list.  It is specifically used to create beans to pass into the grid
> > component source.
> >
> > But the implementation is rather cumbersome.  Is there a way I can use
> the
> > tapestry type coersion infrastructure to do this?  The strategy could be
> > driven by the type of the list elements, and would simply involve moving
> > data with getters and setters.  I woudl invision contributing some
> service
> > which would act on each object in the list, like:
> >
> > translate(Object source, Object destination)
> >
> > Where would be a good place to look in the docs or source code?
> >
> > Ben
> >
>


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

Reply via email to