org.paneris.jammyjoes.shopping
Class Trolley

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by org.melati.servlet.ConfigServlet
              extended by org.melati.servlet.PoemServlet
                  extended by org.melati.servlet.TemplateServlet
                      extended by org.paneris.jammyjoes.shopping.Trolley
All Implemented Interfaces:
java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

public class Trolley
extends org.melati.servlet.TemplateServlet

The Melati Shopping Trolley Interface is designed to provide a flexible adstraction of the basic processes of allowing customers to buy goods on a website. By default, it is not integrated with POEM, and so makes no assumptions about the underlying database implementaion. Please read the readme.txt file for full instructions. The Trolley is a servlet that handles the user's interaction with the Shopping Trolley.

See Also:
org.paneris.melati.shopping.ShoppingTrolley, org.paneris.melati.shopping.ShoppingTrolleyItem, org.paneris.melati.shopping.DefaultShoppingTrolley, org.paneris.melati.shopping.DefaultShoppingTrolleyItem, Serialized Form

Field Summary
 MelatiShoppingConfig config
           
 
Fields inherited from class org.melati.servlet.TemplateServlet
templateEngine
 
Fields inherited from class org.melati.servlet.ConfigServlet
melatiConfig, sysAdminEmail, sysAdminName
 
Constructor Summary
Trolley()
           
 
Method Summary
protected  java.lang.String Abandon(org.melati.Melati melati)
          abandon a trolley
protected  java.lang.String Add(org.melati.Melati melati, java.lang.Integer id, java.lang.Integer quantity)
          add a single item to the trolley, or add to the quantity already in the trolley.
protected  void assertLogin(org.melati.Melati melati)
          force a user to login
protected  java.lang.String CatalogueEntry(org.melati.Melati melati)
          view the trolley
protected  java.lang.String Confirm(org.melati.Melati melati)
          update the user's information and return the confirmation page
protected  java.lang.String Details(org.melati.Melati melati)
          return the page where the user enters their details
protected  java.lang.String doTemplateRequest(org.melati.Melati melati, org.melati.template.ServletTemplateContext context)
          Main entry point for this servlet
 java.lang.String getSysAdminEmail()
           
 java.lang.String getSysAdminName()
           
 void init(javax.servlet.ServletConfig conf)
          Inititialise the Shopping Trolley Engine.
protected  java.lang.String Load(org.melati.Melati melati, java.lang.Integer id)
          load the trolley from something persistent
protected  java.lang.String MultipleAdd(org.melati.Melati melati)
          add multiple items to the trolley, or add to the quantities already in the trolley.
protected  java.lang.String Paid(org.melati.Melati melati)
          complete the user's shopping experience, and remove their Shopping Trolley from the Session If you need to do something (like send an email) following confirmation of payment, define the method in ShoppingTrolley.java: public void confirmPayment(Melati melati) {} Because the callback request (typically) comes from the Payment Server, you will not have the user's shoping trolley (Session) available to them.
protected  org.melati.PoemContext poemContext(org.melati.Melati melati)
          override the building of the MelatiContext in order to glean the additional information required for the Shopping Trolley system
protected  java.lang.String Remove(org.melati.Melati melati, java.lang.Integer id)
          remove a single item from the trolley, the product is specified on the pathinfo which should be of the form: ///Remove/
protected  java.lang.String Save(org.melati.Melati melati)
          load the trolley from something persistent
protected  java.lang.String Set(org.melati.Melati melati, java.lang.Integer id, java.lang.Integer quantity)
          set the quantity of an item in the trolley, the product and new quantity is specified on the pathinfo which should be of the form: ////Set/
protected  java.lang.String Update(org.melati.Melati melati)
          update the entire trolley, changing quantities and removing items.
protected  java.lang.String View(org.melati.Melati melati)
          view the trolley
 
Methods inherited from class org.melati.servlet.TemplateServlet
addExtension, doPoemRequest, error, prePoemSession
 
Methods inherited from class org.melati.servlet.PoemServlet
_handleException, dbBusyMessage, destroy, doConfiguredRequest, handleException, poemContextWithLDB
 
Methods inherited from class org.melati.servlet.ConfigServlet
doGet, doPost, melatiConfig, setSysAdminEmail, setSysAdminName, writeConnectionPendingException, writeError
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service, service
 
Methods inherited from class javax.servlet.GenericServlet
getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

config

public MelatiShoppingConfig config
Constructor Detail

Trolley

public Trolley()
Method Detail

init

public void init(javax.servlet.ServletConfig conf)
          throws javax.servlet.ServletException
Inititialise the Shopping Trolley Engine. This will load a file called org.paneris.melati.shopping.ShoppingTrolley.properties in order to find the classes that implement this shopping implementation

Specified by:
init in interface javax.servlet.Servlet
Overrides:
init in class org.melati.servlet.TemplateServlet
Parameters:
conf - - the Servlet's config parameters
Throws:
javax.servlet.ServletException
See Also:
org.paneris.melati.shopping.MelatiShoppingConfig

getSysAdminName

public java.lang.String getSysAdminName()
Overrides:
getSysAdminName in class org.melati.servlet.PoemServlet

getSysAdminEmail

public java.lang.String getSysAdminEmail()
Overrides:
getSysAdminEmail in class org.melati.servlet.PoemServlet

doTemplateRequest

protected java.lang.String doTemplateRequest(org.melati.Melati melati,
                                             org.melati.template.ServletTemplateContext context)
                                      throws java.lang.Exception
Main entry point for this servlet

Specified by:
doTemplateRequest in class org.melati.servlet.TemplateServlet
Parameters:
melati - - the melati for this request
context - - the Template Context for this request
Returns:
- the name of the template to be returned to the user
Throws:
org.melati.servlet.InvalidUsageException - - if this request has an invalid form
java.lang.Exception

Load

protected java.lang.String Load(org.melati.Melati melati,
                                java.lang.Integer id)
                         throws org.melati.util.InstantiationPropertyException
load the trolley from something persistent

Parameters:
melati - - the melati for this request
id - - an id that can be used to identify the trolley to be loaded
Returns:
- "Trolley" - the page where users manipulate their Shopping Trolley
Throws:
org.melati.util.InstantiationPropertyException - - if we cannot construct trolley

Save

protected java.lang.String Save(org.melati.Melati melati)
                         throws org.melati.util.InstantiationPropertyException
load the trolley from something persistent

Parameters:
melati - - the melati for this request
Returns:
- "Trolley" - the page where users manipulate their Shopping Trolley
Throws:
org.melati.util.InstantiationPropertyException - - if we cannot construct trolley

CatalogueEntry

protected java.lang.String CatalogueEntry(org.melati.Melati melati)
                                   throws org.melati.util.InstantiationPropertyException
view the trolley

Parameters:
melati - - the melati for this request
Returns:
- "Trolley" - the page where users manipulate their Shopping Trolley
Throws:
org.melati.util.InstantiationPropertyException - - if we cannot construct the trolley

View

protected java.lang.String View(org.melati.Melati melati)
                         throws org.melati.util.InstantiationPropertyException
view the trolley

Parameters:
melati - - the melati for this request
Returns:
- "Trolley" - the page where users manipulate their Shopping Trolley
Throws:
org.melati.util.InstantiationPropertyException - - if we cannot construct the trolley

Update

protected java.lang.String Update(org.melati.Melati melati)
                           throws org.melati.util.InstantiationPropertyException
update the entire trolley, changing quantities and removing items. the POSTed form is analysed for fields with names of the form: trolleyitem__quantity - the new quantity of the item (if set) trolleyitem__deleted - remove this item from the trolley (if set) items will also be deleted if the quantity is set to 0

Parameters:
melati - - the melati for this request
Returns:
- "Trolley" - the page where users manipulate their Shopping Trolley
Throws:
org.melati.util.InstantiationPropertyException - - if we cannot construct the trolley

MultipleAdd

protected java.lang.String MultipleAdd(org.melati.Melati melati)
                                throws org.melati.util.InstantiationPropertyException
add multiple items to the trolley, or add to the quantities already in the trolley. The POSTed form is analysed for fields with names of the form: product_ - the id of the item to be added quantity_ - the quantity to add If no quantity is set, a single item will be added.

Parameters:
melati - - the melati for this request
Returns:
- "Trolley" - the page where users manipulate their Shopping Trolley
Throws:
org.melati.util.InstantiationPropertyException - - if we cannot construct trolley

Add

protected java.lang.String Add(org.melati.Melati melati,
                               java.lang.Integer id,
                               java.lang.Integer quantity)
                        throws org.melati.util.InstantiationPropertyException
add a single item to the trolley, or add to the quantity already in the trolley. the product is specified on the pathinfo which should be of the form: ////Add/ if no quantity is set, a single item will be added. The form parmaeters will be parsed to see if they contain "price" and/or "description" fields. if they are present, they will be used to set up the item

Parameters:
melati - - the melati for this request
id - - the id of the item to be added
Returns:
- "Trolley" - the page where users manipulate their Shopping Trolley
Throws:
org.melati.util.InstantiationPropertyException - - if we cannot construct trolley

Remove

protected java.lang.String Remove(org.melati.Melati melati,
                                  java.lang.Integer id)
                           throws org.melati.util.InstantiationPropertyException
remove a single item from the trolley, the product is specified on the pathinfo which should be of the form: ///Remove/

Parameters:
melati - - the melati for this request
Returns:
- "Trolley" - the page where users manipulate their Shopping Trolley
Throws:
org.melati.util.InstantiationPropertyException - - if we cannot construct trolley

Set

protected java.lang.String Set(org.melati.Melati melati,
                               java.lang.Integer id,
                               java.lang.Integer quantity)
                        throws org.melati.util.InstantiationPropertyException
set the quantity of an item in the trolley, the product and new quantity is specified on the pathinfo which should be of the form: ////Set/

Parameters:
melati - - the melati for this request
id - - the id of the item to be removed
Returns:
- "Trolley" - the page where users manipulate their Shopping Trolley
Throws:
org.melati.util.InstantiationPropertyException - - if we cannot construct trolley

Details

protected java.lang.String Details(org.melati.Melati melati)
                            throws org.melati.util.InstantiationPropertyException
return the page where the user enters their details

Parameters:
melati - - the melati for this request
Returns:
- "Details" - the page where users enter their details
Throws:
org.melati.util.InstantiationPropertyException - - if we cannot construct trolley

Confirm

protected java.lang.String Confirm(org.melati.Melati melati)
                            throws org.melati.util.InstantiationPropertyException
update the user's information and return the confirmation page

Parameters:
melati - - the melati for this request
Returns:
- "Confirm" - the page where users confirm their order
Throws:
org.melati.util.InstantiationPropertyException - - if we cannot construct trolley

Paid

protected java.lang.String Paid(org.melati.Melati melati)
                         throws org.melati.util.InstantiationPropertyException
complete the user's shopping experience, and remove their Shopping Trolley from the Session If you need to do something (like send an email) following confirmation of payment, define the method in ShoppingTrolley.java: public void confirmPayment(Melati melati) {} Because the callback request (typically) comes from the Payment Server, you will not have the user's shoping trolley (Session) available to them. You will therefore need to get whatever information you require from something persistent. The alternative is to get the Payment Server to generate the emails (or whatever) for you. Most Payment Servers offer this facility.

Parameters:
melati - - the melati for this request
Returns:
- "Paid" - a message thanking the user for their order
Throws:
org.melati.util.InstantiationPropertyException - - if we cannot construct trolley

Abandon

protected java.lang.String Abandon(org.melati.Melati melati)
                            throws org.melati.util.InstantiationPropertyException
abandon a trolley

Parameters:
melati - - the melati for this request
Returns:
- "Trolley" - the initial trolley page
Throws:
org.melati.util.InstantiationPropertyException - - if we cannot construct trolley

assertLogin

protected void assertLogin(org.melati.Melati melati)
                    throws org.melati.util.InstantiationPropertyException
force a user to login

Parameters:
melati - - the melati for this request
Throws:
org.melati.util.InstantiationPropertyException

poemContext

protected org.melati.PoemContext poemContext(org.melati.Melati melati)
                                      throws org.melati.servlet.PathInfoException
override the building of the MelatiContext in order to glean the additional information required for the Shopping Trolley system

Overrides:
poemContext in class org.melati.servlet.PoemServlet
Parameters:
melati - - the melati for this request
Returns:
- the ShoppingContext with as many bits set up as possible
Throws:
org.melati.servlet.PathInfoException - - if we don't understand the PathInfo


Copyright © 2001-2008 PanEris. All Rights Reserved.