You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Eldred Mullany <el...@easypay.co.za> on 2009/08/21 11:34:28 UTC

Developing a Shopping Cart Component (T5.0.1.5)

Hi There 

 

At some stage in the very near future I need to develop a Shopping Cart
Component that will be session based. The challenge in writing this
would be is to have the cart component updated on the fly when I add
items to the basket (no database must be session based). I have a vague
idea of using an Event Listener that needs to fire a method to update
the component (zone update maybe?) on any page on the website. 

 

I have had a look at Jumpstart sharing data across multiple pages which
is a very simple example. I need some more in depth info or even some
code snippet just to get an idea or if anyone has developed an open
source shopping cart component in T5 that I could look at. 

 

I am not looking for easy way out copy and paste, just info pls and a
few code snippets if someone has done this. 

 

 Many thanks 

Eldred Mullany   

 


Re: Developing a Shopping Cart Component (T5.0.1.5)

Posted by Otho <ta...@googlemail.com>.
That would be one of the perfect fits for a @SessionState object.

@SessionState(create=true)
private ShoppingCart shoppingCart;
...

You can put all logic needed into this class (like addItem(Item it, int
count) and just display it with a ShoppingCartView component.

For example with a simple Parameter you could discern if it is the small
view , which is mostly in the top right corner of the page which only tells
you the number of items and the sum of their prices or the full blown view
needed in the checkout process or in an overview where the customer can
change the number of items to buy or delete them from the basket etc.You
would only need different blocks for each type in the template and delegate
to them depending on the parameter.

public class ShoppingCartView {

@Parameter(required=true, value="small" defaultPrefix="literal")
private String type;
}

2009/8/21 Eldred Mullany <el...@easypay.co.za>

> Hi There
>
>
>
> At some stage in the very near future I need to develop a Shopping Cart
> Component that will be session based. The challenge in writing this
> would be is to have the cart component updated on the fly when I add
> items to the basket (no database must be session based). I have a vague
> idea of using an Event Listener that needs to fire a method to update
> the component (zone update maybe?) on any page on the website.
>
>
>
> I have had a look at Jumpstart sharing data across multiple pages which
> is a very simple example. I need some more in depth info or even some
> code snippet just to get an idea or if anyone has developed an open
> source shopping cart component in T5 that I could look at.
>
>
>
> I am not looking for easy way out copy and paste, just info pls and a
> few code snippets if someone has done this.
>
>
>
>  Many thanks
>
> Eldred Mullany
>
>
>
>

Re: Developing a Shopping Cart Component (T5.0.1.5)

Posted by ael <al...@dash.com.ph>.
Yes i think SSO is the best for this

But in my session class

should i use list? How can i add some data in the cart?

session Class

List<TbCart> cart = new List<TbCart>();

Getter cart.get()

Setter cart.set()


-- 
View this message in context: http://tapestry.1045711.n5.nabble.com/Developing-a-Shopping-Cart-Component-T5-0-1-5-tp2431948p3215938.html
Sent from the Tapestry - User 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