WebORB Presentation Server
AJAX Client Examples

Session Activation Example


Available Fruits: Shopping Cart


Instructions:
'Available Fruits' panel lists all the products you can add to a cart. The cart is maintained in a server-side object. The 'Shopping Cart' panel is a visual representation of the object's 'contents. Select an item in the list and click the 'Add' button to add the item to the cart.


Notes:
In this example, WebORB Rich Client System makes an invocation on a remote object with session activation. As a result, WebORB creates one instance of the class for each browser session. Any time an item is added to the shopping cart, the backend object maintains the state and represents a separate shopping cart for each client.


Implementation:
When browser loads the page, it executes the onLoad handler function. The function binds to a server-side object and requests object's session activation via WebORB's URL. When user clicks the 'Add' button, it issues an asynchronous remote method invocation to add the selected item to the shopping cart. Server responds with the name of the item just added to the cart. When the client program receives the response, Rich Client System invokes the callback specified via the Async object passed into the addItem call.  The callback updates the page with the new item added to the cart