Hi Geoff,

When a LinkSubmit (or Submit) is in an AjaxFormLoop, it appears that
t:defer is always true.  Even when you set it explicitly to false, the
event handler is fired at the end and the t:value (on the
AjaxFormLoop) is always the last value of the loop.  Therefore, when
your LinkSubmit/Submit handler accesses that t:value (or even a
t:context), it gets that last loop value and not the one you clicked
on (unless you clicked on the last one).  At least that's what my
experimentations revealed.

Thanks,

mrg

On Tue, Aug 27, 2013 at 12:06 AM, Geoff Callender
<[email protected]> wrote:
> By design. Default value of LinkSubmit's "defer" parameter is true.
> http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/corelib/components/LinkSubmit.html
>
>
> On 27 August 2013 01:27, Michael Gentry <[email protected]> wrote:
>
>> Hi Ilya,
>>
>> I just used the standard Tapestry LinkSubmit component and, like you
>> said, it exhibits the same issues in an AjaxFormLoop.  I don't know if
>> this is by design or an oversight/bug.
>>
>> mrg
>>
>>
>> On Sat, Aug 24, 2013 at 7:32 PM, Ilya Obshadko <[email protected]>
>> wrote:
>> > Okay, actually replacing t:ajaxformloop with t:loop and setting p:defer
>> to
>> > false helps to resolve this.
>> > Thanks for your feedback.
>> >
>> >
>> > On Sun, Aug 25, 2013 at 10:20 AM, Ilya Obshadko <[email protected]
>> >wrote:
>> >
>> >> Furthermore, replacing t:ajaxformloop with t:loop doesn't help it
>> either.
>> >> Will investigate t:submit source code.
>> >>
>> >>
>> >> On Sun, Aug 25, 2013 at 10:07 AM, Ilya Obshadko <
>> [email protected]>wrote:
>> >>
>> >>> Thank you. Original LinkSubmit has exactly the same issue.
>> >>>
>> >>>
>> >>> On Sunday, August 25, 2013, Michael Gentry wrote:
>> >>>
>> >>>> Hi Ilya,
>> >>>>
>> >>>> I was struggling with the same exact problem yesterday.  Apparently
>> >>>> the AjaxFormLoop doesn't work like a regular Loop and the submit
>> >>>> handler always receives the last iteration value/context.  Even using
>> >>>> t:defer on the Submit didn't help.  I ended up using a LinkSubmit*
>> >>>> with some CSS to make it look like a button and enough t:context
>> >>>> parameters to allow me to figure out which "button" was being clicked
>> >>>> on.
>> >>>>
>> >>>> mrg
>> >>>>
>> >>>> * We have our own custom version of LinkSubmit (which I didn't write,
>> >>>> but is based upon the original) which has a comment at the top about
>> >>>> making LinkSubmit handle t:context correctly in loops.  I don't know
>> >>>> if that was an old issue which is resolved now or if it will impact
>> >>>> you, but wanted to mention it in case LinkSubmit doesn't work for you.
>> >>>>
>> >>>>
>> >>>> On Sat, Aug 24, 2013 at 8:32 AM, Ilya Obshadko <
>> [email protected]>
>> >>>> wrote:
>> >>>> > I have t:ajaxformloop iterating over a property and t:submit using
>> >>>> context
>> >>>> > values from the loop. Code looks like:
>> >>>> >
>> >>>> > @Property
>> >>>> > private SomeType iteratedValue;
>> >>>> >
>> >>>> > void onSelectedFromDoSomething ( SomeType iteratedValue ) {
>> >>>> >   // some stuff depends on iteratedValue here
>> >>>> > }
>> >>>> >
>> >>>> > ----
>> >>>> >
>> >>>> > <t:zone t:id="zoneName">
>> >>>> > <t:ajaxformloop p:source="source" p:value="iteratedValue">
>> >>>> >   <!-- some code here -->
>> >>>> >   <t:submit t:id="doSomething" p:context="iteratedValue"
>> >>>> p:zone="zoneName"/>
>> >>>> >   <!-- some code there -->
>> >>>> > </t:ajaxformloop>
>> >>>> > </t:zone>
>> >>>> >
>> >>>> > At the time of submit iteratedValue *always* contains last iterated
>> >>>> value
>> >>>> > from the loop. Apparently I'm getting wrong results in the end: no
>> >>>> matter
>> >>>> > where submit was clicked, handler always receives the value from the
>> >>>> last
>> >>>> > loop iteration. Any hints how to fix this?
>> >>>> >
>> >>>> >
>> >>>> > --
>> >>>> > Ilya Obshadko
>> >>>>
>> >>>> ---------------------------------------------------------------------
>> >>>> To unsubscribe, e-mail: [email protected]
>> >>>> For additional commands, e-mail: [email protected]
>> >>>>
>> >>>>
>> >>>
>> >>> --
>> >>> Ilya Obshadko
>> >>>
>> >>>
>> >>>
>> >>
>> >>
>> >> --
>> >> Ilya Obshadko
>> >>
>> >>
>> >
>> >
>> > --
>> > Ilya Obshadko
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>>
>>

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to