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

Reply via email to