Simon, Why would the shopping cart be in the ActionMapping? I would think it belongs in the session or new data for the cart would come in to the FORM.
Regards, David -----Original Message----- From: Simon MARTIN [mailto:[EMAIL PROTECTED] Sent: Tuesday, December 07, 2004 7:01 AM To: [EMAIL PROTECTED] Subject: Best practice question: Properties (ShoppingCart) per user Hi, I'm currently writing a short Struts application without a database (I know that this would be better, but as it is only for teaching purposes, I don't want to 'overflow' my audience with databases and ORM). It should be a small online sales system -- I've got ShoppingItems, ShoppingUsers (which are not yet used) and ShoppingCarts. I want a ShoppingCart which stores the ordered items per user. I had something like this: public class ShoppingCartAction extends DispatchAction { private ShoppingCartManager shoppingCartManager; ... public ActionForward order(...) ... public ActionForward list(...) ... } and thought that it would work. Unfortunately, each user (which is not authenticated or anything yet) gets the same shopping cart when he calls shoppingCart.do?method=list. So I did some research and found this: http://www.jguru.com/faq/view.jsp?EID=1057609 So I created an ShoppingCartMapping class public class ShoppingCartMapping extends ActionMapping { private ShoppingCartManager shoppingCartManager; ... } and call it like this public ActionForward list(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { request.setAttribute("orderedItems", ((ShoppingCartMapping)mapping).getShoppingCartManager().getItems()); return mapping.findForward("list"); } which gives me a ClassCastException. Do I have to set my custom ActionMapping in web.xml or struts-config.xml? Am I on the right way, or is there a better way of doing this? Thanks in advande and kind regards, Simon PS: Please cc me in your answers. -- GMX ProMail mit bestem Virenschutz http://www.gmx.net/de/go/mail +++ Empfehlung der Redaktion +++ Internet Professionell 10/04 +++ --------------------------------------------------------------------- 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]