You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by xfile80303 <le...@grokers.net> on 2009/09/10 23:26:18 UTC

[T5.1] Loops, Forms, and Events

Hi all,

Forgive me, please, I'm feeling a bit slow and for the life of me am
struggling with what I think should be a trivial concept...

Please consider this simple example...

Let's say there's a list of products, and one wants to loop over those
products, displaying them as line items in a form in which the user can
change the quantity or remove the items (typical shopping cart
functionality)... something like this:


<form t:id="online">
  <t:loop source="onlineItems" value="lineItem" encoder="itemEncoder">
    <t:actionlink context="lineItem.id">Remove</t:actionlink>
    <input type="text" size="1" id="switch1" class="small qtySmall"
      t:type="textfield" t:value="itemQuantity"/>
    <t:linksubmit>Update Price</t:linksubmit>
  </t:loop>
</form>


There's two concerns here that seem connected in concept:

1) It appears that for this form the only way to handle the actionlink
action is to use the catch all 'onAction(String id)'  which works for this
case just fine, but prevents me from having another action for some other
purpose...  is there no way to identify the event handler in such a way as
to be tied to the 'remove' concept?  Like, onActionFromRemove(String id),
but how does one create this handler for a dynamically identified component,
such as the (many) action links created in the loop?

2) The quantity of the line item is reflected in a text field which the user
can change.  To update the total price, the form must be submitted so the
values of the text fields can be known.  However, to interpret this
submission differently than, say, the actual checkout submission one has to
capture the 'selected' event and set some property appropriately, such that
the onSuccess handler can act accordingly.  Again, the only way seems to be
to use the catch all 'onSelected' handler, and not a specific handler for
this particular type of selected event.

Thanks,

Levi
-- 
View this message in context: http://n2.nabble.com/T5-1-Loops-Forms-and-Events-tp3618845p3618845.html
Sent from the Tapestry Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: [T5.1] Loops, Forms, and Events

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Thu, 10 Sep 2009 21:37:57 -0300, xfile80303 <le...@grokers.net> escreveu:

> Thanks again Thaigo.

You're welcome!

> I can't try this at the moment, but will this work?  The id will end up
> being mylinksubmit0, mylinksubmit1, mylinksubmit2, etc.  Will the
> onSelectedFromMyLinkSubmit() handler get called?

Yes. I've used EventLinks inside Grids and Loops for a long time already.  
The generated element (tag) id is not used as the event name. By the way,  
the HTML attribute id is not the same as Tapestry's t:id (the component  
id). Take a look at the URLs generated by ActionLink or EventLink inside a  
Loop or Grid: all them are the same, except for the context (if any). ;)

-- 
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
http://www.arsmachina.com.br/thiago

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: [T5.1] Loops, Forms, and Events

Posted by xfile80303 <le...@grokers.net>.
Thanks again Thaigo.

I will try an EventLink.

> Doesn't onSelectedFromMyLinkSubmit(Integer id) work in your case? (you  
> would need to add t:id="mylinksubmit" to your LinkSubmit).

I can't try this at the moment, but will this work?  The id will end up
being mylinksubmit0, mylinksubmit1, mylinksubmit2, etc.  Will the
onSelectedFromMyLinkSubmit() handler get called?

Cheers,

Levi


Thiago H. de Paula Figueiredo wrote:
> 
> Em Thu, 10 Sep 2009 18:26:18 -0300, xfile80303 <le...@grokers.net>
> escreveu:
> 
>> purpose...  is there no way to identify the event handler in such a way  
>> as  to be tied to the 'remove' concept?
> 
> Use an EventLink instead of an ActionLink.  # 
> 
>> 2) The quantity of the line item is reflected in a text field which the  
>> user can change.  To update the total price, the form must be submitted  
>> so the
>> values of the text fields can be known.  However, to interpret this
>> submission differently than, say, the actual checkout submission one has  
>> to capture the 'selected' event and set some property appropriately,  
>> such that the onSuccess handler can act accordingly.  Again, the only  
>> way seems to be to use the catch all 'onSelected' handler, and not a  
>> specific handler for
>> this particular type of selected event.
> 
> Doesn't onSelectedFromMyLinkSubmit(Integer id) work in your case? (you  
> would need to add t:id="mylinksubmit" to your LinkSubmit).
> 
> -- 
> Thiago H. de Paula Figueiredo
> Independent Java consultant, developer, and instructor
> http://www.arsmachina.com.br/thiago
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 
> 

-- 
View this message in context: http://n2.nabble.com/T5-1-Loops-Forms-and-Events-tp3618845p3622391.html
Sent from the Tapestry Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: [T5.1] Loops, Forms, and Events

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Thu, 10 Sep 2009 18:26:18 -0300, xfile80303 <le...@grokers.net> escreveu:

> purpose...  is there no way to identify the event handler in such a way  
> as  to be tied to the 'remove' concept?

Use an EventLink instead of an ActionLink. <a href="#" t:type="EventLink"  
t:event="remove" t:context="..."/>

> 2) The quantity of the line item is reflected in a text field which the  
> user can change.  To update the total price, the form must be submitted  
> so the
> values of the text fields can be known.  However, to interpret this
> submission differently than, say, the actual checkout submission one has  
> to capture the 'selected' event and set some property appropriately,  
> such that the onSuccess handler can act accordingly.  Again, the only  
> way seems to be to use the catch all 'onSelected' handler, and not a  
> specific handler for
> this particular type of selected event.

Doesn't onSelectedFromMyLinkSubmit(Integer id) work in your case? (you  
would need to add t:id="mylinksubmit" to your LinkSubmit).

-- 
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
http://www.arsmachina.com.br/thiago

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org