Re: 3 days of ValueEncoder-ing, no coercion found
On Tue, 26 Feb 2013 00:45:51 -0300, mvchris wrote: Oh maan. what an idiot. That's a lesson in reading the stack trace carefully. Bad programmer. It's normal to overlook stuff sometimes . . . :) On looking back at the last message, line 31 just had a loop qmEvents.get(i).getClass.getCanonicalName(); funnily enough as you suspected, the class name was not a LibraryQueueMemberEvent. It was a String from the database query return, which is what I was checking for before I came to the list, half-gone-mad.. Damn, I forgot about that possibility. You may have a scalar query, so it returns a String and not an entity object. Thiago, I am sorry to have wasted your time in the end as it was not a tapestry error. Don't worry. I prefer the feeling of having successfully helped someone. ;) Noted, re nabble and eating stuff. I just stopped using a dedicated desktop mail user agent Gmail and Yahoo are nice and stuff but I still prefer an e-mail client. The Opera's built-in one is quite good and has an integrated RSS reader. and nabble seems like a good tool for browsing. Might have to re-work that workflow because I remember reading stripped posts...frustrating thoughts...ah the karma Nabble is good for browsing (I use it for reading and searching old stuff), not for posting. :) -- Thiago H. de Paula Figueiredo - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: 3 days of ValueEncoder-ing, no coercion found
Oh maan. what an idiot. That's a lesson in reading the stack trace carefully. Bad programmer. On looking back at the last message, line 31 just had a loop qmEvents.get(i).getClass.getCanonicalName(); funnily enough as you suspected, the class name was not a LibraryQueueMemberEvent. It was a String from the database query return, which is what I was checking for before I came to the list, half-gone-mad.. Thiago, I am sorry to have wasted your time in the end as it was not a tapestry error. Noted, re nabble and eating stuff. I just stopped using a dedicated desktop mail user agent and nabble seems like a good tool for browsing. Might have to re-work that workflow because I remember reading stripped posts...frustrating thoughts...ah the karma Kind Regards, Chris -- View this message in context: http://tapestry.1045711.n5.nabble.com/3-days-of-ValueEncoder-ing-no-coercion-found-tp5720109p5720226.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: 3 days of ValueEncoder-ing, no coercion found
Oops, now looking again at your post, now in Nabble, I've noticed something: Caused by: java.lang.ClassCastException: java.lang.String cannot be cast to org.opencsta.ctiserver.library.asterisk.managerevents.model.LibraryQueueMemberEvent at org.opencsta.eventviewer.pages.admin2.AgentStatusList.SetupRender(AgentStatusList.java:31) What's in line 31 of AgentStatusList.SetupRender()? Full method source, please. Without looking at the source yet, it seems this isn't related to Tapestry. -- Thiago H. de Paula Figueiredo - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: 3 days of ValueEncoder-ing, no coercion found
On Fri, 22 Feb 2013 17:17:10 -0300, mvchris wrote: Hi Thiago, Hi! However, since tidying up and gaining a better understanding, the no coercion exception only appears on a grid - I made all my pages as similar as possible for this problem since the start of the week to nut it out - so my question is - how do i know my ValueEncoder is registered with tapestry or is passed to the grid - since it clearly exists and has been contribtued? No every component gets a ValueEncoder automatically from ValueEncoderSource. Even for the ones who do, there may be situations in which ValueEncoderSource isn't enough. It's as though tapestry can't find it with the gridand I'm passing it. Contributing a ValueEncoder to ValueEncoderSource and passing one through a parameter are very different things and maybe you're thinking otherwise. When I ask you if you passed a ValueEncoder to a component, I'm asking about explicitly using the parameter, not contributing to ValueEncoderSource. Now with the loop component: Same page class as the last message posted, with this template below, yields cannot cast exception that follows. Where's the exception? It seems Nabble ate it. By the way, guys, please avoid using Nabble. So has my ValueEncoder created the coercion between String<->LibraryQueueMemberEvent ? No. ValueEncoderSource returns a TypeCoercer-backed ValueEncoder when no contributed one is found for the type. Yet java can't cast between the two for a weird reason? Cast anything that isn't a String to a String? This isn't expected in Java, a statically typed language, at all. In one hand (a grid) my value encoder is not recognised, and in the other (a loop) the coercion has been recognised but at some other level java can't cast between the two? For the third or else time, have you checked the actual type of the objects returned by your persistence provider? They may be subclasses of your entities. With regards to the persistence provider, in this case EclipseLink in Glassfish - I have no idea about returning a subclass. The session bean method is Nabble ate it again. :( Anyway, it wouldn't help. You need to get the list and print the class name. Please print the result of getClass().getName() for each of the Are you saying you've seen Hibernate return a subclass of LibraryQueueMemberEvent - Yes. and how do you overcome that sort of behaviour? Explicitly providing a ValueEncoder (i.e through the encoder parameter parameter). I guess you're relying too much on contributions to ValueEncoderSource even when it's clearly not working. -- Thiago H. de Paula Figueiredo - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: 3 days of ValueEncoder-ing, no coercion found
Hi Thiago, Thanks for the response, I wasn't aware the Loop/Grid thing was a big issue - with either template it had been the same, passing the ValueEncoder. However, since tidying up and gaining a better understanding, the no coercion exception only appears on a grid - I made all my pages as similar as possible for this problem since the start of the week to nut it out - so my question is - how do i know my ValueEncoder is registered with tapestry or is passed to the grid - since it clearly exists and has been contribtued? It's as though tapestry can't find it with the gridand I'm passing it. Now with the loop component: Same page class as the last message posted, with this template below, yields cannot cast exception that follows. So has my ValueEncoder created the coercion between String<->LibraryQueueMemberEvent ? Yet java can't cast between the two for a weird reason? In one hand (a grid) my value encoder is not recognised, and in the other (a loop) the coercion has been recognised but at some other level java can't cast between the two? With regards to the persistence provider, in this case EclipseLink in Glassfish - I have no idea about returning a subclass. The session bean method is Are you saying you've seen Hibernate return a subclass of LibraryQueueMemberEvent - and how do you overcome that sort of behaviour? Thanks for your frustrated reply. I _really_ appreciate your eyeballs on this thread despite what appears my chopping and changing between Loop/Grid. Chris -- View this message in context: http://tapestry.1045711.n5.nabble.com/3-days-of-ValueEncoder-ing-no-coercion-found-tp5720109p5720175.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: 3 days of ValueEncoder-ing, no coercion found
On Fri, 22 Feb 2013 06:09:42 -0300, mvchris wrote: Happy Friday Tapestry Users, Hi! I've been stuck on this all week and really can't move because it's the last part of my app :( I don't understand this thread. Really. We've noticed the problem is in a Loop. Now you post a template with only a Grid. I've suggested you to explicitly pass the ValueEncoder to the Loop's encoder parameter. I said it may be a problem with your persistence provider could have been returning entity subclasses in some cases. No response from you for both questions. -- Thiago H. de Paula Figueiredo - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: 3 days of ValueEncoder-ing, no coercion found
Happy Friday Tapestry Users, I've been stuck on this all week and really can't move because it's the last part of my app :( Then I'm done!! But tapestry is not making it easy to finish. My ValueEncoder is not getting recognised. Here's a good summary of it. 1. I use similar (if not the exact same) Object -> T5 Page -> T5 Template structure between 3 types of objects. My objects are a) CTIConfigurator b) RTQProbe c) LibraryQueueMemberEvent And it works for a list of objects when all values in the DB are fetched from business layer. No need for a value encoder for the grid component on these. The page class looks like this for all of these types And template And this works. I then use the same thing for a different object. Using the grid for all results and it works. My problem exists when I fetch from the business layer a subset of all objects of this type, and I get the coercion exception. I don't know why because it is still a list of objects. So I make a ValueEncoder for LibraryQueueMemberEvent And my AppModule has this added to use my ValueEncoder. It is my only contributedValueEncoder. I'm still getting a coercion exception on a subset of all LibraryQueueMemberEvent objects, which are returned from EJB as a list. The ValueEncoder is declared in the page and template, but somehow not recognised. The template And the page class There are no typos, I've gone over it with a fine toothed comb. Help required :( Thanks Chris -- View this message in context: http://tapestry.1045711.n5.nabble.com/3-days-of-ValueEncoder-ing-no-coercion-found-tp5720109p5720165.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: 3 days of ValueEncoder-ing, no coercion found
I took it out when doing my side-project testing. The findAll() works without a ValueEncoder, yet the other query does not. Here is a ValueEncoder I have used but no luck. Why does findAll() work without a value encoder and the other one doesn't? This part seems irregular. /* * To change this template, choose Tools | Templates * and open the template in the editor. */ package org.opencsta.eventviewer.encoders; import javax.ejb.EJB; import org.apache.tapestry5.ValueEncoder; import org.apache.tapestry5.services.ValueEncoderFactory; import org.opencsta.ctiserver.library.asterisk.managerevents.model.LibraryQueueMemberEvent; import org.opencsta.ctiserver.library.asterisk.managerevents.session.LibraryQueueMemberEventFacadeLocal; /** * * @author chrismylonas */ public class LibraryQueueMemberEventEncoder implements ValueEncoder, ValueEncoderFactory { private LibraryQueueMemberEventFacadeLocal _libraryQueueMemberService; public LibraryQueueMemberEventEncoder(LibraryQueueMemberEventFacadeLocal qmService) { this._libraryQueueMemberService = qmService; } @Override public String toClient(LibraryQueueMemberEvent v) { return String.valueOf(v.getId()); } @Override public LibraryQueueMemberEvent toValue(String id) { return _libraryQueueMemberService.find(Long.valueOf(id)); } @Override public ValueEncoder create(Class type) { ;// } } -- View this message in context: http://tapestry.1045711.n5.nabble.com/3-days-of-ValueEncoder-ing-no-coercion-found-tp5720109p5720135.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: 3 days of ValueEncoder-ing, no coercion found
On Wed, 20 Feb 2013 18:25:28 -0300, mvchris wrote: Hi Thiago et al, Sure can, what follows is the template, page class, session bean, implementation and entity with named queries. You didn't explicitly provided a ValueEncoder to your source. Could you please try that? -- Thiago H. de Paula Figueiredo - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: 3 days of ValueEncoder-ing, no coercion found
nabble ate my template, hopefully the raw tag works. -- View this message in context: http://tapestry.1045711.n5.nabble.com/3-days-of-ValueEncoder-ing-no-coercion-found-tp5720109p5720131.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: 3 days of ValueEncoder-ing, no coercion found
Hi Thiago et al, Sure can, what follows is the template, page class, session bean, implementation and entity with named queries. I discovered this behaviour when I ripped this stuff out into a side project and made a mock list of objects to display...and it worked. Note that there are no complex types in the entity, all just String/Integer/Boolean. No value encoder. findAll() works. Returns 132 objects in List. getMostRecentDistinctByQueue() does not. Returns 3 objects in List. I've refactored from LibraryEvent to LibraryQueueMemberEvent overnight as I work on other parts of the app. Same exception(s)... Here is AgentStatusList.tml using a loop http://tapestry.apache.org/schema/tapestry_5_3.xsd";> About EventViewer application ... id status membership location queue ${qmevent.id} ${qmevent.status} ${qmevent.membership} ${qmevent.location} ${qmevent.queue} And here is the page class /* * To change this template, choose Tools | Templates * and open the template in the editor. */ package org.opencsta.eventviewer.pages; import java.util.List; import javax.ejb.EJB; import org.apache.tapestry5.ValueEncoder; import org.apache.tapestry5.annotations.Property; import org.opencsta.ctiserver.library.asterisk.managerevents.model.LibraryQueueMemberEvent; import org.opencsta.ctiserver.library.asterisk.managerevents.session.LibraryQueueMemberEventFacadeLocal; import org.opencsta.eventviewer.encoders.LibraryQueueMemberEventEncoder; /** * * @author chrismylonas */ public class AgentStatusList { @EJB private LibraryQueueMemberEventFacadeLocal queueMemberService; @Property private LibraryQueueMemberEvent qmevent; //@Property //private LibraryQueueMemberEventEncoder lqmeEncoder ; public List getQMEvents() { List a = queueMemberService.getMostRecentDistinctByQueue("2720102"); System.out.println("MYLO THE SIZE OF QMEVENTS IS " + a.size() ); return a; } } This is using the Jumpstart method of getting the @EJB annotation to work. I have had success in using Lenny's Flowlogix library, I'm not at the stage to incorporate it into my workflow for this project. Here is the @Local session bean interface /* * To change this template, choose Tools | Templates * and open the template in the editor. */ package org.opencsta.ctiserver.library.asterisk.managerevents.session; import java.util.List; import javax.ejb.Local; import org.opencsta.ctiserver.library.asterisk.managerevents.model.LibraryQueueMemberEvent; /** * * @author chrismylonas */ @Local public interface LibraryQueueMemberEventFacadeLocal { void create(LibraryQueueMemberEvent libraryQueueMemberEvent); void edit(LibraryQueueMemberEvent libraryQueueMemberEvent); void remove(LibraryQueueMemberEvent libraryQueueMemberEvent); LibraryQueueMemberEvent find(Object id); List findAll(); List findRange(int[] range); int count(); public LibraryQueueMemberEvent getMostRecentByQueueNumberAndMember( String queueNumber, String qMember); public List getMostRecentDistinctByQueue(String queueNumber); } And the implementing class /* * To change this template, choose Tools | Templates * and open the template in the editor. */ package org.opencsta.ctiserver.library.asterisk.managerevents.session; import java.util.List; import javax.ejb.Stateless; import javax.persistence.EntityManager; import javax.persistence.PersistenceContext; import javax.persistence.Query; import org.opencsta.ctiserver.library.asterisk.managerevents.model.LibraryQueueMemberEvent; /** * * @author chrismylonas */ @Stateless public class LibraryQueueMemberEventFacade extends AbstractFacade implements LibraryQueueMemberEventFacadeLocal { @PersistenceContext(unitName = "InfrastructureEM") private EntityManager em; @Override protected EntityManager getEntityManager() { return em; } public LibraryQueueMemberEventFacade() { super(LibraryQueueMemberEvent.class); } @Override public LibraryQueueMemberEvent getMostRecentByQueueNumberAndMember(String queueNumber, String qMember) { Query query = getEntityManager().createNamedQuery(LibraryQueueMemberEvent.QUERY_GETLATESTBYQNUMANDAGENT); query.setMaxResults(1); query.setParameter(LibraryQueueMemberEvent.QUERY_PARAMETER_QNUM, queueNumber); query.setParameter(LibraryQueueMemberEvent.QUERY_PARAMETER_QMEM, qMember); return (LibraryQueueMemberEvent) query.getSingleResult(); } @Override public List getMostRecentDistinctByQueue(String queueNumber){ Query query = getEntityManager().createNamedQuery(LibraryQueueMemberEvent.QUERY_GETDISTINCTLOCATION); //query.setMaxResults(50); query.setParam
Re: 3 days of ValueEncoder-ing, no coercion found
On Wed, 20 Feb 2013 09:54:15 -0300, mvchris wrote: Whether I use a grid or a loop, my EJB findAll() method which returns all records - it displays the records without a problem. If I use my getDistinct() method, I get the no coercion error. This may be related to the JPA implementation returning runtime-created subclasses of entity classes (in this case, LibraryEvent). I've seen Hibernate do that. org.apache.tapestry5.ioc.internal.util.TapestryException: Failure writing parameter 'value' of component AgentStatusList:loop: Could not find a coercion from type java.lang.String to type au.com.mrvoip.libt5.model.LibraryEvent. [at classpath: au/com/mrvoip/libt5/pages/AgentStatusList.tml, line 15] You had posted a Grid, but in fact your exception is happening in a Loop. Could you post the part of the template that declares this Loop instance? -- Thiago H. de Paula Figueiredo - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: 3 days of ValueEncoder-ing, no coercion found
Noted the use of DefaultProvider where grid's is optional. And yes, I remember reading a million times not to do what I posted - thanks for highlighting that! -- View this message in context: http://tapestry.1045711.n5.nabble.com/3-days-of-ValueEncoder-ing-no-coercion-found-tp5720109p5720119.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: 3 days of ValueEncoder-ing, no coercion found
OK - I have some peculiar repeatable behaviour... (no use of value encoder for testing and my findAll() works but smaller subset of results, still List object used for source) Whether I use a grid or a loop, my EJB findAll() method which returns all records - it displays the records without a problem. If I use my getDistinct() method, I get the no coercion error. Both EJB methods return List objects. The findAll() returns 132 in the list, whereas the getDistinct() returns 3. When calling findAll(), everything works. getDistinct() though, no coercion. Any thoughts? Thanks a lot Chris Here is the top of the stacktrace, but it looks like a normal "can't find coercion" message: [#|2013-02-20T23:47:48.276+1100|SEVERE|glassfish3.1.2|tapestry.render.org.opencsta.eventviewer.pages.AgentStatusList|_ThreadID=112;_ThreadName=Thread-2;|Render queue error in BeginRender[AgentStatusList:loop]: Failure writing parameter 'value' of component AgentStatusList:loop: Could not find a coercion from type java.lang.String to type au.com.mrvoip.libt5.model.LibraryEvent. org.apache.tapestry5.ioc.internal.util.TapestryException: Failure writing parameter 'value' of component AgentStatusList:loop: Could not find a coercion from type java.lang.String to type au.com.mrvoip.libt5.model.LibraryEvent. [at classpath: au/com/mrvoip/libt5/pages/AgentStatusList.tml, line 15] -- View this message in context: http://tapestry.1045711.n5.nabble.com/3-days-of-ValueEncoder-ing-no-coercion-found-tp5720109p5720118.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: 3 days of ValueEncoder-ing, no coercion found
On Wed, 20 Feb 2013 01:49:36 -0300, Chris Mylonas wrote: Hi Tapestry List, long time no hear... Hi! Welcome back! There are no lmevents to display; you can add some manually when the link is made. Have you checked in the Tapestry error page exactly where in your template this happens? I guess it's not related to Grid. As Taha said, there are some components that need a ValueEncoder but don't get one automatically. -- Thiago H. de Paula Figueiredo - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: 3 days of ValueEncoder-ing, no coercion found
Thanks for the pointers Taha - interesting that those ValueEncoders have slightly different behaviours depending Let me get some traces with a smaller sample project to try and help my cause. It's my first tapestry project in nearly a year! -- View this message in context: http://tapestry.1045711.n5.nabble.com/3-days-of-ValueEncoder-ing-no-coercion-found-tp5720109p5720112.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: 3 days of ValueEncoder-ing, no coercion found
Excuse me, the contribute method in the previous email was not the one used for coercion errors. It should have looked like this public static void contributeValueEncoderSource( MappedConfiguration, ValueEncoderFactory> configuration) { configuration.addInstance(LibraryEvent.class, LibraryEncoder.class); } and with this one I just implemented the method required for implementing the ValueEncoderFactory on my encoder. On Wed, Feb 20, 2013 at 3:49 PM, Chris Mylonas wrote: > Hi Tapestry List, long time no hear... > > How do you make tapestry spit out what encoder/coercions are supported. > My encoder doesn't seem to be getting registered > > I am writing an app and have had to use a ValueEncoder. I don't know > where I am going wrong, I've written them before...and for the past 3 days > get the same stupid coercion message. > > My understanding is > 1. Write encoder that implements ValueEncoder > 2. Contribute to value encoders > 3. encoder="myNewEncoder" in the tapestry component to use where no > coercions come out-of-the-box > > I have tried two alternatives and would like to know where I've gone wrong > in either please. > > 1. Using Igor's Tapestry 5 book, I wrote a class called > LibraryEventEncoder and placed it in an uncontrolled package, it implements > ValueEncoder. > > package au.com.mrvoip.t5app.encoders ; > > public class LibraryEventEncoder implements ValueEncoder { > > private LibraryEventFacadeLocal _libraryEventService; > > public LibraryEventEncoder(LibraryEventFacadeLocal libraryService) { > this._libraryEventService = libraryService; > > } > > @Override > public String toClient(LibraryEvent v) { > return String.valueOf(v.getId()); > } > > @Override > public LibraryEvent toValue(String id) { > return _libraryEventService.find(Long.valueOf(id)); > } > } > > > AppModule receives this addition > > > @Contribute(ValueEncoderSource.class) > public static void provideEncoders(MappedConfiguration ValueEncoderFactory>configuration, final LibraryEventFacadeLocal lqmefl){ > System.out.println("CHRIS THIS HAS BEEN CONTRIBUTED"; > ValueEncoderFactory factory = new > ValueEncoderFactory(){ > public ValueEncoder create(Class > clazz){ > return new LibraryEventEncoder(lqmefl); > } > }; > > configuration.add(LibraryEvent.class, factory); > } > > > My page class uses a simple grid and the template follows > > @EJB > private LibraryEventFacadeLocal libraryService; > @Property > private LibraryEvent lmevent; > > @Property > private LibraryEventEncoder libeventEncoder = new > LibraryEventEncoder(); > > public List getLMEvents() { > > return libraryService.getMostRecentDistinct("2720101"); //returns > a short list (3-10 results usually) > } > > public ValueEncoder getLibEventEncoder(){ > return libEventEncoder ; > } > > > > rowsPerPage="50" > > > There are no lmevents to display; you can add some > manually when the link is made. > > > > > > > And the alternate way which appears to be popular - some private inner > class as a replacement, as well as something like this directly in the get > method. > > public LibraryEventEncoder getLibEventEncoder() { > return new LibraryEventEncoder(lmService) { > public String toClient(LibraryEvent value) { > return String.valueOf(value.getId()); > } > > public LibraryEvent toValue(String clientValue) { > LibraryEvent e = > libEventService.find(Long.valueOf(clientValue)); > if (String.valueOf(e.getId()).equals(clientValue)) { > return e; > } > return null; > } > }; > } > > > But all the time I'm getting a problem with coercion of String to > LibraryEvent even with the System.out.println message being spat out of > logs that this encoder is being contributed (or at least i think it is) > > > Any pointers would be helpful > Chris > > -- -- sent from web mail --
Re: 3 days of ValueEncoder-ing, no coercion found
Hi Chris You have not shared the trace so I can't help you much but there are certain things I thought might help in general. Contributing a ValueEncoder to a ValueEncoderSource only helps in components which use the ComponentDefaultProvider#defaultValueEncoder e.g. Select, Palette etc. For a Grid component, encoder is an optional parameter and does not use a default implementation. Thus in your case it is not in use. As Thiago has pointed out a million times, NEVER EVER initialize a field inline in a component/page use setupRender()/onActivate() Remember these are not solution to your problem, just suggestions. For a solution please share the full stack-trace :) regards Taha On Feb 20, 2013, at 10:19 AM, Chris Mylonas wrote: > Hi Tapestry List, long time no hear... > > How do you make tapestry spit out what encoder/coercions are supported. My > encoder doesn't seem to be getting registered > > I am writing an app and have had to use a ValueEncoder. I don't know where > I am going wrong, I've written them before...and for the past 3 days get > the same stupid coercion message. > > My understanding is > 1. Write encoder that implements ValueEncoder > 2. Contribute to value encoders > 3. encoder="myNewEncoder" in the tapestry component to use where no > coercions come out-of-the-box > > I have tried two alternatives and would like to know where I've gone wrong > in either please. > > 1. Using Igor's Tapestry 5 book, I wrote a class called > LibraryEventEncoder and placed it in an uncontrolled package, it implements > ValueEncoder. > > package au.com.mrvoip.t5app.encoders ; > > public class LibraryEventEncoder implements ValueEncoder { > >private LibraryEventFacadeLocal _libraryEventService; > >public LibraryEventEncoder(LibraryEventFacadeLocal libraryService) { >this._libraryEventService = libraryService; > >} > >@Override >public String toClient(LibraryEvent v) { >return String.valueOf(v.getId()); >} > >@Override >public LibraryEvent toValue(String id) { >return _libraryEventService.find(Long.valueOf(id)); >} > } > > > AppModule receives this addition > > >@Contribute(ValueEncoderSource.class) >public static void provideEncoders(MappedConfiguration ValueEncoderFactory>configuration, final LibraryEventFacadeLocal lqmefl){ >System.out.println("CHRIS THIS HAS BEEN CONTRIBUTED"; >ValueEncoderFactory factory = new > ValueEncoderFactory(){ >public ValueEncoder create(Class > clazz){ >return new LibraryEventEncoder(lqmefl); >} >}; > >configuration.add(LibraryEvent.class, factory); >} > > > My page class uses a simple grid and the template follows > >@EJB >private LibraryEventFacadeLocal libraryService; >@Property >private LibraryEvent lmevent; > >@Property >private LibraryEventEncoder libeventEncoder = new LibraryEventEncoder(); > >public List getLMEvents() { > >return libraryService.getMostRecentDistinct("2720101"); //returns a > short list (3-10 results usually) >} > >public ValueEncoder getLibEventEncoder(){ >return libEventEncoder ; >} > > > > rowsPerPage="50" > > > There are no lmevents to display; you can add some > manually when the link is made. > > > > > > > And the alternate way which appears to be popular - some private inner > class as a replacement, as well as something like this directly in the get > method. > >public LibraryEventEncoder getLibEventEncoder() { >return new LibraryEventEncoder(lmService) { >public String toClient(LibraryEvent value) { >return String.valueOf(value.getId()); >} > >public LibraryEvent toValue(String clientValue) { >LibraryEvent e = > libEventService.find(Long.valueOf(clientValue)); >if (String.valueOf(e.getId()).equals(clientValue)) { >return e; >} >return null; >} >}; >} > > > But all the time I'm getting a problem with coercion of String to > LibraryEvent even with the System.out.println message being spat out of > logs that this encoder is being contributed (or at least i think it is) > > > Any pointers would be helpful > Chris