1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package net.sf.imca.web.backingbeans;
17
18 import javax.faces.model.SelectItem;
19 import net.sf.imca.model.AssociationBO;
20 import net.sf.imca.services.JoinImcaService;
21
22
23
24
25
26
27 public class MemTypeBean {
28
29 private String area = "";
30
31 private String countryCode = "";
32
33 private String memTypeId = "";
34
35
36
37
38 private String userFeedbackMessage = "";
39
40 private boolean countryIsOfficiallyImca = false;
41
42 private SelectItem[] membershipTypeItems;
43
44 JoinImcaService service = new JoinImcaService();
45
46 public String actionJoin() {
47 if (!("".equals(countryCode))
48 && !("".equals(memTypeId)) ) {
49 return Utils.ACTION_SUCCESS;
50 } else {
51 return Utils.ACTION_FAIL;
52 }
53 }
54
55 public boolean getCountryHasAreas(){
56 if (getAreaItems().length > 1) {
57 return true;
58 } else {
59 return false;
60 }
61 }
62
63
64
65 public SelectItem[] getAreaItems(){
66 JoinImcaService service = new JoinImcaService();
67 String[] areas = service.getAreasForCountry(countryCode);
68
69 SelectItem[] items = new SelectItem[areas.length];
70 for (int i=0; i < items.length; i++) {
71 items[i] = new SelectItem(areas[i]);
72 }
73 return items;
74 }
75
76 public String getArea() {
77 return area;
78 }
79
80 public void setArea(String area) {
81 this.area = area;
82 }
83
84 public String getCountryCode() {
85 if (countryCode.equals("")) {
86 WebUser webUser = (WebUser) Utils
87 .getManagedBean(Utils.WEB_USER_BEAN_NAME);
88 countryCode = webUser.getPerson().getEntity().getAddress().getCountryCode();
89 }
90 return countryCode;
91 }
92
93 public void setCountryCode(String countryCode) {
94 this.countryCode = countryCode;
95
96 AssociationBO association = service.selectAssociation(countryCode, area);
97 if (association == null) {
98 this.countryIsOfficiallyImca = false;
99 association = service.selectAssociation(AssociationBO.IMCA_WORLD_COUNTRY_CODE, "");
100 } else {
101 this.countryIsOfficiallyImca = association.getEntity().getIsOfficiallyImca();
102 }
103 }
104
105 public String getMemTypeId() {
106 return memTypeId;
107 }
108
109 public void setMemTypeId(String memTypeId) {
110 this.memTypeId = memTypeId;
111 }
112
113 public String getUserFeedbackMessage() {
114 return userFeedbackMessage;
115 }
116
117 public void setUserFeedbackMessage(String userFeedbackMessage) {
118 this.userFeedbackMessage = userFeedbackMessage;
119 }
120
121 public boolean getCountryIsOfficiallyImca() {
122 return countryIsOfficiallyImca;
123 }
124
125 public SelectItem[] getMembershipTypeItems() {
126 return membershipTypeItems;
127 }
128
129 public void setMembershipTypeItems(SelectItem[] membershipTypeItems) {
130 this.membershipTypeItems = membershipTypeItems;
131 }
132
133 }