Re: [5.3.6] Saving loop-generated checkbox values between requests
You are correct, I'll have to lookup the whole objects from the database again and providing a value encoder sounds like the most seamless approach. Thanks a lot for your help :) On Fri, Dec 28, 2012 at 12:30 PM, Lance Java wrote: > The problem with ITERATION is that you need to lookup the values when the > form is posted. If these came from a database there is a chance that the > list has changed between rendering the form and posting the form. > > I suggest that you either pass an "encoder" parameter to the loop or you > contribute to the ValueEncoderSource or TypeCoercer. > > > > -- > View this message in context: > http://tapestry.1045711.n5.nabble.com/5-3-6-Saving-loop-generated-checkbox-values-between-requests-tp5719034p5719042.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: [5.3.6] Saving loop-generated checkbox values between requests
The problem with ITERATION is that you need to lookup the values when the form is posted. If these came from a database there is a chance that the list has changed between rendering the form and posting the form. I suggest that you either pass an "encoder" parameter to the loop or you contribute to the ValueEncoderSource or TypeCoercer. -- View this message in context: http://tapestry.1045711.n5.nabble.com/5-3-6-Saving-loop-generated-checkbox-values-between-requests-tp5719034p5719042.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: [5.3.6] Saving loop-generated checkbox values between requests
> The thing is that "VALUES" serializes the "device" object using toString That's not entirely true. Tapestry uses a ValueEncoder to serialize / deserialize your values. If you don't provide an "encoder" parameter to the loop, it will use the ValueEncoderSource to find on which is ultimately backed by the TypeCoercer. http://tapestry.apache.org/type-coercion.html -- View this message in context: http://tapestry.1045711.n5.nabble.com/5-3-6-Saving-loop-generated-checkbox-values-between-requests-tp5719034p5719041.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: [5.3.6] Saving loop-generated checkbox values between requests
Thanks a lot ! It's coming along now. I first faced a problem with the loop state so I disabled it (i.e. NONE) but after you pointed out the javadoc, I tried the "ITERATION" option that keeps info sufficient info for iterating over the values only and its working now. The thing is that "VALUES" serializes the "device" object using toString and even as its a waste of time to deserialize that. that's not what I need, I only need a string property acquired from it (IP). Thanks again :) On Fri, Dec 28, 2012 at 10:38 AM, Lance Java wrote: > The Loop component has a "formState" parameter which defaults to > LoopFormState.VALUES. This means that by default, the Loop component > serializes the loop values into a hidden field in your form. The values are > then reconstructed serverside when the form is posted. > > > http://tapestry.apache.org/5.3.6/apidocs/org/apache/tapestry5/corelib/components/Loop.html > > http://tapestry.apache.org/5.3.6/apidocs/org/apache/tapestry5/corelib/LoopFormState.html > > Can you provide a bit more code? In particular, how "ipSelection" and > "device" are constructed / persisted? > > > > -- > View this message in context: > http://tapestry.1045711.n5.nabble.com/5-3-6-Saving-loop-generated-checkbox-values-between-requests-tp5719034p5719038.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: [5.3.6] Saving loop-generated checkbox values between requests
The Loop component has a "formState" parameter which defaults to LoopFormState.VALUES. This means that by default, the Loop component serializes the loop values into a hidden field in your form. The values are then reconstructed serverside when the form is posted. http://tapestry.apache.org/5.3.6/apidocs/org/apache/tapestry5/corelib/components/Loop.html http://tapestry.apache.org/5.3.6/apidocs/org/apache/tapestry5/corelib/LoopFormState.html Can you provide a bit more code? In particular, how "ipSelection" and "device" are constructed / persisted? -- View this message in context: http://tapestry.1045711.n5.nabble.com/5-3-6-Saving-loop-generated-checkbox-values-between-requests-tp5719034p5719038.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
[5.3.6] Saving loop-generated checkbox values between requests
I have a numerous checkboxes generated withing a loop that is even inside another loop Loop Loop Checkbox So I set the checkbox's value this way: So the "ipSelection" method accepts an ip, looks up a map of objects that have a "selected" boolean property. Now the "device" property isn't persisted among requests so an exception occurs while submitting the form. I'm only trying to persist state of selected checkboxes among requests. And I'm confused why solution doesn't work, and after giving it a little thought, I'm not sure why should it work ! I implemented a similar approach but that had a static text as the provided parameter (i.e. method('myKey'))