What he said. So you do this:
Page class:
@Property
private Product product;
public List<Product> getProducts() {
// return the products you want to show
...
}
// or onAddToCart(Long productId) if you feel like using EventLink
Object onActionFromAddToCart(Long productId) {
// load the product and do whatever you need to do with it
...
// redirect to shopping cart or wherever
}
Page template:
<t:loop t:source="products" t:value="product">
<!-- display the product -->
<t:actionlink t:id="addtocart" t:context="product.id">Add to
cart</t:actionlink>
...
</t:loop>
Hope that helps.
-Filip
On 2008-05-17 14:03, Robert Zeigler wrote:
Stick in a single action link.
It will take care of "uniquifying" its id.
Then write a single handler.
Put the instance-specific information in the context for the action
link, and then your handler can accept that info as method parameters.
Robert
On May 17, 2008, at 5/176:51 AM , Tomasz Dziurko wrote:
You understood me very correcltly :)
But I have loop with products and each product has 'add to cart' link.
AFAIK it's not possible to use ActionLink in loop, cause every
ActionLink must have unique id and when I don't know how many items
will be in the loop it's hard do write methods connected to each
AcionLink.
PageLink, which you mentioned. seems to be created to different
purposes... so problem is still unresolved :)
---------------------------------------------------------------------
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]