1 package org.gnomekr.potron.web.view; 2 3 import static org.gnomekr.potron.util.NavigationCases.NAV_LANGUAGE_TEAM_ADD; 4 import static org.gnomekr.potron.util.NavigationCases.NAV_LANGUAGE_TEAM_LIST; 5 6 import java.io.UnsupportedEncodingException; 7 import java.util.Date; 8 import java.util.List; 9 10 import javax.faces.application.FacesMessage; 11 12 import org.apache.myfaces.util.MessageUtils; 13 import org.gnomekr.potron.data.LanguageTeam; 14 import org.gnomekr.potron.service.IProjectManager; 15 16 /*** 17 * LanguageTeamView.java 18 * @author Xavier Cho 19 * @version $Revision 1.1 $ $Date: 2005/07/17 08:08:32 $ 20 * @jsf.bean 21 * name = "languageTeam" 22 * scope = "request" 23 * @jsf.navigation 24 * from = "*" 25 * to = "/admin/team/add.jsf" 26 * result = "language.team.add" 27 * @jsf.navigation 28 * from = "*" 29 * to = "/admin/team/update.jsf" 30 * result = "language.team.update" 31 * @jsf.navigation 32 * from = "*" 33 * to = "/admin/team/list.jsf" 34 * result = "language.team.list" 35 */ 36 public class LanguageTeamView extends AbstractFacesView { 37 38 private IProjectManager manager; 39 40 private long id = -1; 41 private String name; 42 private String contact; 43 private String encoding; 44 private String prefix; 45 private Date registeredDate; 46 47 /*** 48 * @return 49 * @jsf.managed-property 50 * value = "#{projectManager}" 51 */ 52 public IProjectManager getManager() { 53 return manager; 54 } 55 56 public String addLanguageTeam() { 57 LanguageTeam team = new LanguageTeam(); 58 team.setName(name); 59 team.setContact(contact); 60 team.setPrefix(prefix); 61 team.setEncoding(encoding); 62 63 try { 64 new String("".getBytes(encoding)); 65 } catch (UnsupportedEncodingException e) { 66 MessageUtils.addMessage( 67 FacesMessage.SEVERITY_WARN, 68 "error.unknown.encoding", 69 null); 70 71 return NAV_LANGUAGE_TEAM_ADD; 72 } 73 74 manager.addLanguageTeam(team); 75 76 MessageUtils.addMessage( 77 FacesMessage.SEVERITY_INFO, 78 "msg.language.team.add.successful", 79 null); 80 81 return NAV_LANGUAGE_TEAM_LIST; 82 } 83 84 public String updateLanguageTeam() { 85 LanguageTeam team = manager.getLanguageTeam(id); 86 87 team.setName(name); 88 team.setContact(contact); 89 team.setPrefix(prefix); 90 team.setEncoding(encoding); 91 92 manager.updateLanguageTeam(team); 93 94 MessageUtils.addMessage( 95 FacesMessage.SEVERITY_INFO, 96 "msg.language.team.update.successful", 97 null); 98 99 return NAV_LANGUAGE_TEAM_LIST; 100 } 101 102 public String removeLanguageTeam() { 103 manager.removeLanguageTeam(id); 104 105 MessageUtils.addMessage( 106 FacesMessage.SEVERITY_INFO, 107 "msg.language.team.remove.successful", 108 null); 109 110 return NAV_LANGUAGE_TEAM_LIST; 111 } 112 113 public List<LanguageTeam> getLanguageTeams() { 114 return manager.getLanguageTeams(); 115 } 116 117 /*** 118 * @return Returns the contact. 119 */ 120 public String getContact() { 121 return contact; 122 } 123 124 /*** 125 * @param contact The contact to set. 126 */ 127 public void setContact(String contact) { 128 this.contact = contact; 129 } 130 131 /*** 132 * @return Returns the encoding. 133 */ 134 public String getEncoding() { 135 return encoding; 136 } 137 138 /*** 139 * @param encoding The encoding to set. 140 */ 141 public void setEncoding(String encoding) { 142 this.encoding = encoding; 143 } 144 145 /*** 146 * @return Returns the id. 147 */ 148 public long getId() { 149 return id; 150 } 151 152 /*** 153 * @param id The id to set. 154 */ 155 public void setId(long id) { 156 this.id = id; 157 158 LanguageTeam team = manager.getLanguageTeam(id); 159 160 if (team != null) { 161 this.name = team.getName(); 162 this.contact = team.getContact(); 163 this.prefix = team.getPrefix(); 164 this.encoding = team.getEncoding(); 165 this.registeredDate = team.getRegisteredDate(); 166 } 167 } 168 169 /*** 170 * @return Returns the name. 171 */ 172 public String getName() { 173 return name; 174 } 175 176 /*** 177 * @param name The name to set. 178 */ 179 public void setName(String name) { 180 this.name = name; 181 } 182 183 /*** 184 * @return Returns the prefix. 185 */ 186 public String getPrefix() { 187 return prefix; 188 } 189 190 /*** 191 * @param prefix The prefix to set. 192 */ 193 public void setPrefix(String prefix) { 194 this.prefix = prefix; 195 } 196 197 /*** 198 * @return Returns the registeredDate. 199 */ 200 public Date getRegisteredDate() { 201 return registeredDate; 202 } 203 204 /*** 205 * @param registeredDate The registeredDate to set. 206 */ 207 public void setRegisteredDate(Date registeredDate) { 208 this.registeredDate = registeredDate; 209 } 210 211 /*** 212 * @param manager The manager to set. 213 */ 214 public void setManager(IProjectManager manager) { 215 this.manager = manager; 216 } 217 }