When you need to persist non-trivial state (and not want to put it in the session, like standard @Persist does), you need to help tapestry figure out how to map between a String and the persistent state.
There are some coercers for the most trivial types and projects like tapestry-hibernate/jpa also automatically let tapestry know how to map between String and Entity instances. Some tapestry components allows you to register an encoder for the mapping back and forth and on some pages you might need to perform the mapping manually ( using activate/passivate ) Barry suggested a variation of this (because the parameter he passes is a String which requires no further translation) and then you have the chance to initialize "users" prior to rendering. Beware that setupRender phase is not always executed; ajax requests, form submissions etc. may bypass it - Activate is always performed - So one should be careful about the amount of work performed during activation. > And Tapestry thinks "model.Street$0040141f225" is a String but it should be > a Bean. > > I tried adding Serializable on my Street bean but it doesn't change the > error. As tapestry does not know how to map from your "Street" instance to a String, if attempts to use the ordinary Java toString(), probably resulting in something like "Street@141f225" and when this string is passed back in, it has no chance of getting back to the correct Street instance. A ValueEncoder<Street> could probably do this for you automatically (you have to let it know how to map from your instance to a String and back again). Another possibility is to remove the @Activation* parameters and perform the mapping in the page activate/passivate methods. HTH. -- Chris On Wed, Apr 27, 2016 at 8:20 AM, Morgan Hautman <morgan.haut...@gmail.com> wrote: > Hi, > > I didn't managed to get it work with @ActivationRequestParameter. > I tried everything out and the last try was with @Persist and it worked, so > I'm keeping that because nothing else works.. > > Thank you all. > > Regards, > Morgan > > 2016-04-26 13:06 GMT+02:00 Barry Books <trs...@gmail.com>: > > > Sorry my previous response a bit short. I was on my phone. Something like > > this hibernate example should work. It's better to store the query > > parameters in the URL instead of the session. If you use the session > > returning to the page will rerun the last query which seems a bit weird > for > > a web app. All the work is done in setupRender instead of onSuccess > because > > onSuccess ends with a redirect so no page is rendered. > > > > @Property > > List<User> users; > > > > @Property > > @ActivationRequestParameter > > String lastName; > > > > @Inject > > Session session; > > > > @SetupRender > > void setupRender() { > > if ( lastName != null ) { > > users = session.createQuery(" from User where lastName = > > :lastName").setParameter("lastName",lastName).list(); > > } > > } > > > > > > > > > > On Tuesday, April 26, 2016, Morgan Hautman <morgan.haut...@gmail.com> > > wrote: > > > > > Hi, > > > > > > The problem was that I had no get/setters in my Bean I displayed.. > > > > > > Now it renders well on the first page but when I click on the second > > page I > > > have: > > > > > > Caused by: org.apache.tapestry5.ioc.util.UnknownValueException: Could > not > > > find a coercion from type java.lang.String to type java.util.Set. > > > > > > I think this is because the url looks like this: > > > > > > > > > http://localhost:8090/***/searchstreet.grid.pager/2?t:ac=model.Street$0040141f225/model.Street$0040868971 > > > . > > > .. > > > > > > And Tapestry thinks "model.Street$0040141f225" is a String but it > should > > be > > > a Bean. > > > > > > I tried adding Serializable on my Street bean but it doesn't change the > > > error. > > > > > > Any idea? > > > > > > Regards, > > > Morgan > > > > > > > > > 2016-04-25 16:05 GMT+02:00 Barry Books <trs...@gmail.com > > <javascript:;>>: > > > > > > > Use @pageactvation context and put what's in your onSucess method in > > > > setupRender > > > > > > > > On Monday, April 25, 2016, Morgan Hautman <morgan.haut...@gmail.com > > > <javascript:;>> > > > > wrote: > > > > > > > > > Hi, > > > > > > > > > > Thank you guys. > > > > > I first tried the fix stated by Felix (@PageActivationContext) but > it > > > > > doesn't work. > > > > > I then tried the ajax way Nathan provided and I have better results > > but > > > > my > > > > > grid shows 4 pages/links but I don't see any data. > > > > > > > > > > I added > > > > > > > > > > <t:zone t:id="zoneGrid" id="zoneGrid"> > > > > > <div/> > > > > > <t:grid source="streets" row="street"> > > > > > *[Grid here]* > > > > > </t:grid> > > > > > </t:zone> > > > > > > > > > > but still no luck, any one has a pointer? > > > > > > > > > > Regards, > > > > > Morgan > > > > > > > > > > 2016-04-25 12:07 GMT+02:00 Nathan Quirynen < > > > nat...@pensionarchitects.be <javascript:;> > > > > > <javascript:;>>: > > > > > > > > > > > Hey, > > > > > > > > > > > > By returning "this" in the onSuccess event, a redirect happens > > > > resulting > > > > > > in a new request. If you want to preserve data between requests, > > you > > > > will > > > > > > have to save it into the http session. > > > > > > If you add http session persistence, the data will be available > > > after a > > > > > > new request. < > http://tapestry.apache.org/persistent-page-data.html > > > > > > > > > > > > > > > Simple example for your case: > > > > > > > > > > > > @Persist > > > > > > @Property > > > > > > private Set<Street> streets;|| > > > > > > > > > > > > > > > > > > Be careful: in this case the whole streets set is saved into the > > http > > > > > > session and will remain there until the end of the session (or > > until > > > > you > > > > > > remove it manually). > > > > > > You could also persist the form vaues instead and then in > > setupRender > > > > > > event fill the trees set based on these values. > > > > > > Also you can make use of PersistenceConstants.FLASH to let > Tapestry > > > > > remove > > > > > > it from the session after first access automatically. > > > > > > See more info: > > > http://tapestry.apache.org/persistent-page-data.html|| > > > > > > > > > > > > Another option is making use of AJAX where the updated grid html > is > > > > sent > > > > > > back in the response and updated on the client side. If you want > to > > > > > achieve > > > > > > this you'll need to add a Zone around the grid and make your Form > > > > submit > > > > > > with AJAX. > > > > > > > > > > > > Your case: > > > > > > > > > > > > <t:form t:zone="zoneGrid"> > > > > > > ... > > > > > > <t:zone t:id="zoneGrid" id="zoneGrid" > > > > > > <t:grid source="streets" row="street"> > > > > > > </t:grid> > > > > > > </t:zone> > > > > > > <t:form> > > > > > > > > > > > > @Inject > > > > > > private AjaxResponseRenderer ajax; > > > > > > @InjectComponent > > > > > > private Zone zoneGrid; > > > > > > > > > > > > void onSuccess() { > > > > > > ... > > > > > > ajax.addRender(zoneGrid); > > > > > > } > > > > > > > > > > > > See more info: http://tapestry.apache.org/ajax-and-zones.html > > > > > > > > > > > > > > > > > > Hope this helps u a bit. > > > > > > Nathan > > > > > > > > > > > > > > > > > > On 25/04/16 11:05, Morgan Hautman wrote: > > > > > > > > > > > >> Hi, > > > > > >> > > > > > >> I'm trying to make a make grid update when submitting a form > > within > > > > the > > > > > >> same page. > > > > > >> > > > > > >> Here is the code: > > > > > >> > https://gist.github.com/mhautman/e178fdcca46331e1f4932b1cd7074de7 > > > > > >> > > > > > >> The page gets refreshed but the table/source doesn't seem to be > > > > updated. > > > > > >> > > > > > >> Any help is greatly appreciated. > > > > > >> > > > > > >> Regards, > > > > > >> Morgan > > > > > >> > > > > > >> > > > > > > > > > > > > > > > > > > > > >