What you can do is to make @Persist(PersistanceConstants.CLIENT) and retrieve 
only id of the object ( not object, because it may go to broken reference ) of 
the object between AJAX calls. With that id pass values of that object between 
calls. It's much safer and consumes less server resources than @SessionState.

> Date: Fri, 24 Oct 2014 11:50:04 -0400
> Subject: Re: Could not find a coercion from type java.lang.String to type 
> org.tapdemo.demo.entity.TimeSheet
> From: gchrist...@cardaddy.com
> To: users@tapestry.apache.org
> 
> I'm facing a problem where the object hasn't yet been committed to the db
> and there for the object has no id. This is probably the root of this
> exception.
> 
>  I'm trying to build an ajax wizard where each step has it's own ajax form
> and the db commit will be handled at the end. I was hoping to just pass in
> the value form form A into the context of form B, but that may not be
> possible without an id.
> 
> I suppose I could use @SessionState or in the past I've copied the form
> data from form a to form b and sent the original form data out of view, but
> I've been hoping to come up with a better solution than those two since
> processing form A data requires a lot of system resources.
> 
> On Fri, Oct 24, 2014 at 11:35 AM, Chris Poulsen <mailingl...@nesluop.dk>
> wrote:
> 
> > Pass the object key as a simple type (string/long) and setup the object in
> > the PREPARE_FOR_SUBMIT handler.
> >
> >
> >
> > On Fri, Oct 24, 2014 at 5:22 PM, George Christman <gchrist...@cardaddy.com
> > >
> > wrote:
> >
> > > Unfortunately the valueencoder is not an option for the form component.
> > >
> > > On Fri, Oct 24, 2014 at 11:09 AM, Name Surname <
> > wintertime0...@outlook.com
> > > >
> > > wrote:
> > >
> > > > Hey George. I had a very similar situation. What you can do here is to
> > > > make a new Encoder and put it into appropriate field. Take a look at my
> > > > example.
> > > >
> > > >    private class DateEncoder implements ValueEncoder<Date> {
> > > >
> > > >         @Override
> > > >         public String toClient(Date date) {
> > > >             long timeMillis = date.getTime();
> > > >             return Long.toString(timeMillis);
> > > >         }
> > > >
> > > >         @Override
> > > >         public Date toValue(String timeMillisAsString) {
> > > >             long timeMillis = Long.parseLong(timeMillisAsString);
> > > >             Date date = new Date(timeMillis);
> > > >             return date;
> > > >         }
> > > >
> > > >     }
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >                     and I put into a grid( in your case it will be
> > grid )
> > > > encoder value, something like encoder="dateEncoder". This should work
> > > just
> > > > fine for your case.
> > > >
> > > >
> > > > > Date: Fri, 24 Oct 2014 11:02:02 -0400
> > > > > Subject: Could not find a coercion from type java.lang.String to type
> > > > org.tapdemo.demo.entity.TimeSheet
> > > > > From: gchrist...@cardaddy.com
> > > > > To: users@tapestry.apache.org
> > > > >
> > > > > Hi Guys, I have a form contained within a zone where I'm passing an
> > > > object
> > > > > into the context value. When I submit the form I get the following
> > > > > exception.
> > > > >
> > > > > *parameter #1: org.apache.tapestry5.ioc.util.UnknownValueException:
> > > Could
> > > > > not find a coercion from type java.lang.String to type
> > > > > org.tapdemo.demo.entity.TimeSheet.*
> > > > >
> > > > > .tml
> > > > >
> > > > > <t:zone t:id="formZone" id="formZone">
> > > > >         <t:form t:id="form" zone="formZone" context="ts">
> > > > >
> > > > >         <t:submit t:event="save" context="action.notification"/>
> > > > >
> > > > > java class
> > > > >
> > > > > public enum Action {
> > > > >         WARNING, NOTIFICATION, CERTIFICATION
> > > > > }
> > > > >
> > > > > @Property
> > > > >     private TimeSheetEntity ts;
> > > > >
> > > > > public void onPrepareForSubmitFromForm(TimeSheetEntity ts) {
> > > > >     this.ts = ts;
> > > > >     }
> > > > >
> > > > >     public void onSave(Action action) {
> > > > >         this.action = action;
> > > > >     }
> > > > >
> > > > > Aren't you able to pass an object into context? Any ideas what might
> > be
> > > > > happening here?
> > > > >
> > > > > --
> > > > > George Christman
> > > > > www.CarDaddy.com
> > > > > P.O. Box 735
> > > > > Johnstown, New York
> > > >
> > > >
> > >
> > >
> > >
> > > --
> > > George Christman
> > > www.CarDaddy.com
> > > P.O. Box 735
> > > Johnstown, New York
> > >
> >
> 
> 
> 
> -- 
> George Christman
> www.CarDaddy.com
> P.O. Box 735
> Johnstown, New York
                                          

Reply via email to