1 16 package dlog4j.formbean; 17 18 import java.util.ArrayList ; 19 import java.util.Date ; 20 import java.util.List ; 21 import java.util.StringTokenizer ; 22 23 import javax.servlet.http.HttpServletRequest ; 24 25 import org.apache.struts.action.ActionError; 26 import org.apache.struts.action.ActionErrors; 27 import org.apache.struts.action.ActionMapping; 28 29 33 public class LogForm extends LogBaseForm { 34 35 public final static int STATUS_NORMAL = 0x00; 36 public final static int STATUS_HIDDEN = 0x02; 37 public final static int STATUS_DELETED= 0x04; 38 39 CategoryForm category; 40 String searchKey; 41 int viewCount; 42 int replyCount; 43 List replies; 44 List trackBacks; 45 Date deleteTime; 46 int replyNotify = 0; 47 int status = STATUS_NORMAL; 48 49 52 public ActionErrors validate(ActionMapping arg0, HttpServletRequest arg1) { 53 ActionErrors errors = new ActionErrors(); 54 if(getCategoryId()==-1) 55 errors.add("categoryId",new ActionError("log_category_not_assign")); 56 if(title==null||title.length()==0) 57 errors.add("title",new ActionError("log_title_not_assign")); 58 if(content==null||content.length()==0) 59 errors.add("content",new ActionError("log_content_not_assign")); 60 if(author==null||author.length()==0) 61 errors.add("author",new ActionError("not_empty_allow")); 62 if(authorUrl==null||authorUrl.length()==0) 63 errors.add("authorUrl",new ActionError("not_empty_allow")); 64 return errors; 65 } 66 67 public String getSearchKey() { 68 return searchKey; 69 } 70 public String [] getSearchKeys(){ 71 if(searchKey==null) 72 return null; 73 ArrayList keys = new ArrayList (); 74 StringTokenizer st = new StringTokenizer (searchKey); 75 while(st.hasMoreElements()){ 76 keys.add(st.nextToken()); 77 } 78 return (String [])keys.toArray(new String [keys.size()]); 79 } 80 public void setSearchKey(String searchKey) { 81 this.searchKey = searchKey; 82 } 83 84 public int getCategoryId(){ 85 return (category!=null)?category.getId():-1; 86 } 87 88 public void setCategoryId(int catId){ 89 if(category==null) 90 category = new CategoryForm(); 91 category.setId(catId); 92 } 93 94 97 public CategoryForm getCategory() { 98 return category; 99 } 100 101 102 105 public List getReplies() { 106 return replies; 107 } 108 109 112 public int getReplyCount() { 113 return replyCount; 114 } 115 116 119 public int getViewCount() { 120 return viewCount; 121 } 122 123 126 public void setCategory(CategoryForm form) { 127 category = form; 128 } 129 130 133 public void setReplies(List list) { 134 replies = list; 135 } 136 137 140 public void setReplyCount(int i) { 141 replyCount = i; 142 } 143 144 147 public void setViewCount(int i) { 148 viewCount = i; 149 } 150 151 154 public int getStatus() { 155 return status; 156 } 157 158 161 public void setStatus(int i) { 162 status = i; 163 } 164 public List getTrackBacks() { 165 return trackBacks; 166 } 167 public void setTrackBacks(List trackBacks) { 168 this.trackBacks = trackBacks; 169 } 170 public Date getDeleteTime() { 171 return deleteTime; 172 } 173 public void setDeleteTime(Date deleteTime) { 174 this.deleteTime = deleteTime; 175 } 176 public int getReplyNotify() { 177 return replyNotify; 178 } 179 public void setReplyNotify(int replyNotify) { 180 this.replyNotify = replyNotify; 181 } 182 } 183 | Popular Tags |