KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tapestry > pets > presentation > pages > EditAccountPage


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 // setLanguage(customer.getProfile().getLangPref());
38
// setFavoriteCategory(customer.getProfile().getFavCategory());
39
// setMyListOn(customer.getProfile().getMyListOpt());
40
// setBannersOn(customer.getProfile().getBannerOpt());
41

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 no error message, advance to the Results page,
55
// otherwise, stay here and show the error message.
56
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 JavaDoc(0));
79                 newCustomer.setBanneropt(new Integer JavaDoc(0));
80
81                 // if (Account.updateCustomerAccount(newCustomer))
82
// {
83
// visit.setCustomer(newCustomer);
84
// visit.setBannerpath(null);
85
// getEngine().setLocale(new
86
// Locale(newCustomer.getProfile().getLangPref()));
87
//
88
// cycle.activate("UpdatAccountSuccess");
89
// }
90
}
91         }
92     }
93
94     public abstract String JavaDoc getGivenName();
95
96     public abstract String JavaDoc getAddress1();
97
98     public abstract String JavaDoc getAddress2();
99
100     public abstract String JavaDoc getCity();
101
102     public abstract String JavaDoc getFamilyName();
103
104     public abstract String JavaDoc getFavoriteCategory();
105
106     public abstract String JavaDoc getLanguage();
107
108     public abstract String JavaDoc getPostalCode();
109
110     public abstract String JavaDoc getStateOrProvince();
111
112     public abstract String JavaDoc getTelephoneNumber();
113
114     public abstract String JavaDoc getUserEmail();
115
116     public abstract String JavaDoc getUserName();
117
118     public abstract void setUserName(String JavaDoc username);
119
120     public abstract String JavaDoc getCountry();
121
122     public abstract void setAddress1(String JavaDoc Address1);
123
124     public abstract void setAddress2(String JavaDoc Address2);
125
126     public abstract void setCity(String JavaDoc city);
127
128     public abstract void setCountry(String JavaDoc country);
129
130     public abstract void setFamilyName(String JavaDoc familyName);
131
132     public abstract void setFavoriteCategory(String JavaDoc favoriteCategory);
133
134     public abstract void setGivenName(String JavaDoc givenName);
135
136     public abstract void setLanguage(String JavaDoc language);
137
138     public abstract void setPostalCode(String JavaDoc postalCode);
139
140     public abstract void setStateOrProvince(String JavaDoc state_or_province);
141
142     public abstract void setTelephoneNumber(String JavaDoc telephone_number);
143
144     public abstract void setUserEmail(String JavaDoc 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