Shopping Cart in It

Embed Size (px)

Citation preview

public void init() { DBTransactionImpl trx = (DBTransactionImpl)getDBTransaction(); ApplicationModuleImpl am = (ApplicationModuleImpl)trx.getRootApplicationModule(); String user = am.getUserPrincipalName().toUpperCase(); System.out.println("The session user is: " + user); ViewObjectImpl vo; vo = getShoppingCart1(); String bindUser = (String)vo.getNamedWhereClauseParam("CurrentUser"); if (! user.equals(bindUser)) { vo.setNamedWhereClauseParam("CurrentUser", user); /* The ShoppingCart is guaranteed to only have one row. * However, we may not always properly initialize this * from the UI because the actual row from ShoppingCart is * not really needed. The following initializes the view * object so that the view link to the shopping cart items * properly works. */ vo.executeQuery(); Row cart = vo.first(); if (cart == null) { cart = vo.createRow(); // TODO: Need to finish this off. cart.setAttribute("OrderDate", ((DBTransactionImpl)getDBTransaction()).getCurrentDbTime()); cart.setAttribute("OrderStatusCode", "CART"); vo.insertRow(cart); } }}