1 package org.apache.tapestry.pets.presentation.pages; 2 3 import johnmammen.betterpetshop.bo.Useraccount; 4 5 import org.apache.tapestry.IRequestCycle; 6 import org.apache.tapestry.event.PageEvent; 7 import org.apache.tapestry.event.PageRenderListener; 8 import org.apache.tapestry.pets.ProtectedPage; 9 import org.apache.tapestry.pets.Visit; 10 import org.apache.tapestry.pets.domain.model.ICustomer; 11 import org.apache.tapestry.valid.ValidationDelegate; 12 13 public abstract class EditAccountPage extends ProtectedPage implements 14 PageRenderListener { 15 16 public void pageBeginRender(PageEvent event) { 17 Visit visit = (Visit) getVisit(); 18 setUserName(visit.getCustomer().getUserid()); 19 getCustomerDetails(); 20 } 21 22 public void getCustomerDetails() { 23 Visit visit = (Visit) getVisit(); 24 ICustomer customer = visit.getCustomer(); 25 26 if (customer != null) { 27 setUserEmail(customer.getEmail()); 28 setGivenName(customer.getFirstname()); 29 setFamilyName(customer.getLastname()); 30 setAddress1(customer.getAddr1()); 31 setAddress2(customer.getAddr2()); 32 setCity(customer.getCity()); 33 setStateOrProvince(customer.getState()); 34 setCountry(customer.getCountry()); 35 setPostalCode(customer.getZip()); 36 setTelephoneNumber(customer.getPhone()); 37 42 setLanguage(customer.getLangpref()); 43 setFavoriteCategory(customer.getBannerdata().getFavcategory()); 44 setMyListOn(true); 45 setBannersOn(false); 46 } 47 } 48 49 public void directUpdateAccount(IRequestCycle cycle) { 50 { 51 ValidationDelegate delegate = (ValidationDelegate) getBeans() 52 .getBean("delegate"); 53 54 if (!delegate.getHasErrors()) { 57 Visit visit = (Visit) getVisit(); 58 ICustomer oldCustomer = visit.getCustomer(); 59 ICustomer newCustomer = new Useraccount(); 60 61 boolean lopt = isMyListOn() ? true : false; 62 boolean bopt = isBannersOn() ? true : false; 63 64 newCustomer.setUserid(oldCustomer.getUserid()); 65 newCustomer.setEmail(getUserEmail()); 66 newCustomer.setFirstname(getGivenName()); 67 newCustomer.setLastname(getFamilyName()); 68 newCustomer.setStatus(visit.getCustomer().getStatus()); 69 newCustomer.setAddr1(getAddress1()); 70 newCustomer.setAddr2(getAddress2()); 71 newCustomer.setCity(getCity()); 72 newCustomer.setState(getStateOrProvince()); 73 newCustomer.setZip(getPostalCode()); 74 newCustomer.setCountry(getCountry()); 75 newCustomer.setPhone(getTelephoneNumber()); 76 newCustomer.setLangpref(getLanguage()); 77 newCustomer.getBannerdata().setFavcategory(getFavoriteCategory()); 78 newCustomer.setMylistopt(new Integer (0)); 79 newCustomer.setBanneropt(new Integer (0)); 80 81 } 91 } 92 } 93 94 public abstract String getGivenName(); 95 96 public abstract String getAddress1(); 97 98 public abstract String getAddress2(); 99 100 public abstract String getCity(); 101 102 public abstract String getFamilyName(); 103 104 public abstract String getFavoriteCategory(); 105 106 public abstract String getLanguage(); 107 108 public abstract String getPostalCode(); 109 110 public abstract String getStateOrProvince(); 111 112 public abstract String getTelephoneNumber(); 113 114 public abstract String getUserEmail(); 115 116 public abstract String getUserName(); 117 118 public abstract void setUserName(String username); 119 120 public abstract String getCountry(); 121 122 public abstract void setAddress1(String Address1); 123 124 public abstract void setAddress2(String Address2); 125 126 public abstract void setCity(String city); 127 128 public abstract void setCountry(String country); 129 130 public abstract void setFamilyName(String familyName); 131 132 public abstract void setFavoriteCategory(String favoriteCategory); 133 134 public abstract void setGivenName(String givenName); 135 136 public abstract void setLanguage(String language); 137 138 public abstract void setPostalCode(String postalCode); 139 140 public abstract void setStateOrProvince(String state_or_province); 141 142 public abstract void setTelephoneNumber(String telephone_number); 143 144 public abstract void setUserEmail(String UserEmail); 145 146 public abstract void setMyListOn(boolean myListOn); 147 148 public abstract boolean isMyListOn(); 149 150 public abstract boolean isBannersOn(); 151 152 public abstract void setBannersOn(boolean bannersOn); 153 } | Popular Tags |