1 20 21 package golfShop.presentation.xmlc.checkout; 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 org.w3c.dom.*; 29 import org.w3c.dom.html.*; 30 import golfShop.presentation.xmlc.utilities.*; 31 import golfShop.presentation.xmlc.cart.*; 32 import golfShop.spec.user.UserDO; 33 34 import golfShop.spec.cart.*; 35 import golfShop.presentation.xmlc.utilities.CartUtils; 36 import com.lutris.appserver.server.session.Session; 37 38 43 public class Main implements HttpPresentation { 44 47 private Cart cart; 48 49 52 private UserDO user; 53 54 57 private void addUserToTable(MainHTML htmlObj) { 58 try{ 60 htmlObj.setTextUserName(HtmlEncoder.encode(user.getName())); 61 62 63 HTMLInputElement address1 = htmlObj.getElementAddress1(); 65 address1.setValue(user.getAddress1()); 66 67 HTMLInputElement address2 = htmlObj.getElementAddress2(); 68 address2.setValue(user.getAddress2()); 69 70 HTMLInputElement city = htmlObj.getElementCity(); 71 city.setValue(user.getCity()); 72 73 HTMLInputElement state = htmlObj.getElementState(); 74 state.setValue(user.getState()); 75 76 HTMLInputElement zip = htmlObj.getElementZip(); 77 zip.setValue(user.getZip()); 78 79 HTMLInputElement email = htmlObj.getElementEmail(); 80 email.setValue(user.getEmail()); 81 82 HTMLInputElement cardnum = htmlObj.getElementCreditCard(); 83 if((user.getCreditCard() != null) && (user.getCreditCard().length() > 0)) 84 cardnum.setValue(user.getCreditCard()); 85 86 87 } catch(NullPointerException ex) { 88 } 89 } 90 91 92 95 private void outputPage(HttpPresentationComms comms) 96 throws HttpPresentationException { 97 MainHTML htmlObj 98 = (MainHTML)comms.xmlcFactory.create(MainHTML.class); 99 ContentsTableFormatter.fillInTable(htmlObj, cart, false); 100 addUserToTable(htmlObj); 101 comms.response.writeDOM(htmlObj); 102 } 103 104 107 public void run(HttpPresentationComms comms) 108 throws HttpPresentationException { 109 110 cart = CartUtils.getCart(comms.session); 111 user = (UserDO)comms.session.getUser(); 112 outputPage(comms); 113 } 114 } 115 | Popular Tags |