1 16 17 package info.jtrac.util; 18 19 import info.jtrac.Jtrac; 20 import info.jtrac.domain.User; 21 import java.beans.PropertyEditorSupport ; 22 23 26 public class UserEditor extends PropertyEditorSupport { 27 28 private Jtrac jtrac; 29 30 public UserEditor(Jtrac jtrac) { 31 this.jtrac = jtrac; 32 } 33 34 @Override 35 public void setAsText(String text) { 36 if (text == null || text.equals("")) { 37 setValue(null); 38 } else { 39 int id = Integer.parseInt(text); 40 setValue(jtrac.loadUser(id)); 41 } 42 } 43 44 @Override 45 public String getAsText() { 46 Object o = getValue(); 47 if (o == null) { 48 return ""; 49 } 50 User user = (User) o; 51 return user.getId() + ""; 52 } 53 54 } 55 | Popular Tags |