Replacing default type coercer

Andrias Sundskarð <[email protected]>
Newsgroups gmane.comp.java.tapestry.user
Message-ID <VI1PR03MB16162A198A39191C01454284A6F10@VI1PR03MB1616.eurprd03.prod.outlook.com>
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?
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.