1 20 21 package golfShop.presentation.xmlc.main; 22 23 import org.enhydra.xml.xmlc.*; 24 import org.enhydra.xml.xmlc.html.*; 25 import com.lutris.util.*; 26 import com.lutris.appserver.server.httpPresentation.*; 27 import java.io.*; 28 import java.net.URLEncoder ; 29 import org.w3c.dom.*; 30 import org.w3c.dom.html.*; 31 import golfShop.presentation.xmlc.utilities.*; 32 import golfShop.spec.LoginException; 33 48 public class Item implements HttpPresentation { 49 52 private static final String buyPO = "Buy.po"; 53 54 57 private static final String CART_CONTENTS_URL = "../cart/Contents.po"; 58 59 62 private static final String defaultItem = "noItem.html"; 63 64 67 private String add; 68 69 72 private String ref; 73 74 77 private Long newItem; 78 79 82 private void outputPage(HttpPresentationComms comms) 83 throws HttpPresentationException { 84 ItemHTML htmlObj = (ItemHTML)comms.xmlcFactory.create(ItemHTML.class); 85 86 HTMLFrameElement buyFrame = htmlObj.getElementBuy(); 87 String buyUrl = buyPO; 88 if (add != null) { 89 buyUrl += "?add=" + URLEncoder.encode(add); 90 } 91 buyFrame.setSrc(buyUrl); 92 93 htmlObj.getElementItem().setSrc(ref); 94 95 comms.response.writeDOM(htmlObj); 96 } 97 98 101 private void parseArgs(HttpPresentationRequest request) 102 throws HttpPresentationException { 103 104 add = request.getParameter("add"); 105 ref = request.getParameter("ref"); 106 if (ref == null) { 107 ref = defaultItem; 108 } 109 String newItemStr = request.getParameter("newItem"); 110 if (newItemStr != null) { 111 newItem = new Long (newItemStr); 112 } 113 } 114 115 118 public void run(HttpPresentationComms comms) 119 throws HttpPresentationException { 120 121 parseArgs(comms.request); 122 if (newItem != null) { 123 CartUtils.addItem(comms.session, newItem.longValue()); 124 ref = CART_CONTENTS_URL; 125 } 126 outputPage(comms); 127 } 128 } 129 | Popular Tags |