That might work, but I'm thinking that the type coercer solution is more like 
"code once, fix every page", right? Or am I misunderstanding you reply? Could 
you provide some code example?

However, the question on how to replace an existing type coercer remains. Is 
that not possible?

-----Original Message-----
From: Thiago H. de Paula Figueiredo [mailto:thiag...@gmail.com] 
Sent: 31. maj 2017 20:51
To: Tapestry users <users@tapestry.apache.org>
Subject: Re: Replacing default type coercer

Hi!

Why don't you just pass a GridDataSource directly instead of relying on having 
your collection coerced to it?

On Wed, May 31, 2017 at 10:41 AM, Andrias Sundskarð <a...@amc.dk> wrote:

> Hi, guys.
>
> I'm using tapestry 5.3.8.
>
> I need a different grid sorting than the one provided in 
> "CollectionGridDataSource".
> I contribute a custom type coercer like this:
>
> public static void contributeTypeCoercer(Configuration<CoercionTuple>
> configuration)
> {
>                              
> configuration.add(CoercionTuple.create(Collection.class,
> GridDataSource.class,
>                                      new Coercion<Collection,
> GridDataSource>()
>                                      {
>                                                                   @Override
>                                                                   
> public GridDataSource coerce(Collection input)
>                                                                   {
>
>                      return new MyCollectionGridDataSource(input);
>                                                                   }
>                                      })); }
>
> My code seems to work without issues, but at random times 
> "MyCollectionGridDataSource" is not being used. These times the 
> standard "CollectionGridDataSource" is used instead. I have verified 
> this by setting break point in both classes.
>
> Configuration list before adding custom type coercer:
> org.apache.tapestry5.ComponentResources --> org.apache.tapestry5.
> PropertyOverrides
> String --> org.apache.tapestry5.SelectModel java.util.Map --> 
> org.apache.tapestry5.SelectModel java.util.Collection --> 
> org.apache.tapestry5.grid.GridDataSource
> null --> org.apache.tapestry5.grid.GridDataSource
> java.util.List --> org.apache.tapestry5.SelectModel String --> 
> java.util.regex.Pattern 
> org.apache.tapestry5.runtime.ComponentResourcesAware --> 
> org.apache.tapestry5.ComponentResources
> String --> org.apache.tapestry5.Renderable 
> org.apache.tapestry5.Renderable --> org.apache.tapestry5.Block String 
> --> java.text.DateFormat String --> org.apache.tapestry5.ioc.Resource 
> org.apache.tapestry5.Renderable --> org.apache.tapestry5.runtime.
> RenderCommand
> java.util.Date --> java.util.Calendar
> org.apache.tapestry5.ioc.Resource --> org.apache.tapestry5.services.
> dynamic.DynamicTemplate
> org.apache.tapestry5.Asset --> org.apache.tapestry5.ioc.Resource 
> String --> org.apache.tapestry5.corelib.ClientValidation
> org.apache.tapestry5.services.ComponentClassTransformWorker -->
> org.apache.tapestry5.services.transform.ComponentClassTransformWorker2
> org.apache.tapestry5.ValueEncoder --> org.apache.tapestry5.services.
> ValueEncoderFactory
> org.apache.tapestry5.services.InjectionProvider -->
> org.apache.tapestry5.services.transform.InjectionProvider2
>
> and after:
> org.apache.tapestry5.ComponentResources --> org.apache.tapestry5.
> PropertyOverrides
> String --> org.apache.tapestry5.SelectModel java.util.Map --> 
> org.apache.tapestry5.SelectModel java.util.Collection --> 
> org.apache.tapestry5.grid.GridDataSource
> null --> org.apache.tapestry5.grid.GridDataSource
> java.util.List --> org.apache.tapestry5.SelectModel String --> 
> java.util.regex.Pattern 
> org.apache.tapestry5.runtime.ComponentResourcesAware --> 
> org.apache.tapestry5.ComponentResources
> String --> org.apache.tapestry5.Renderable 
> org.apache.tapestry5.Renderable --> org.apache.tapestry5.Block String 
> --> java.text.DateFormat String --> org.apache.tapestry5.ioc.Resource 
> org.apache.tapestry5.Renderable --> org.apache.tapestry5.runtime.
> RenderCommand
> java.util.Date --> java.util.Calendar
> org.apache.tapestry5.ioc.Resource --> org.apache.tapestry5.services.
> dynamic.DynamicTemplate
> org.apache.tapestry5.Asset --> org.apache.tapestry5.ioc.Resource 
> String --> org.apache.tapestry5.corelib.ClientValidation
> org.apache.tapestry5.services.ComponentClassTransformWorker -->
> org.apache.tapestry5.services.transform.ComponentClassTransformWorker2
> org.apache.tapestry5.ValueEncoder --> org.apache.tapestry5.services.
> ValueEncoderFactory
> org.apache.tapestry5.services.InjectionProvider -->
> org.apache.tapestry5.services.transform.InjectionProvider2
> java.util.Collection --> org.apache.tapestry5.grid.GridDataSource
>
> As seen here it seems that my custom coercer does not replace the 
> existing one.
>
> How can I replace the existing type coercer with my own?
>



--
Thiago

Reply via email to