1 16 package dlog4j.formbean; 17 18 import javax.servlet.http.HttpServletRequest ; 19 20 import java.util.List ; 21 22 import org.apache.commons.lang.StringUtils; 23 import org.apache.struts.action.ActionError; 24 import org.apache.struts.action.ActionErrors; 25 import org.apache.struts.action.ActionForm; 26 import org.apache.struts.action.ActionMapping; 27 28 36 public class CategoryForm extends ActionForm { 37 38 public final static int TYPE_OWNER = 0x00; public final static int TYPE_GENERAL = 0x01; public final static int TYPE_COMMON = 0x02; 43 44 private String iconUrl; 45 46 47 private int type; 48 49 50 private int order = -1; 52 53 private String name; 54 55 56 private int id = -1; 57 58 59 private List logs; 60 61 private SiteForm site; 62 63 private int logCount = 0; 64 65 public boolean isCommon(){ 67 return type == TYPE_COMMON; 68 } 69 public boolean isOwnerOnly(){ 70 return type == TYPE_OWNER; 71 } 72 78 public ActionErrors validate( 79 ActionMapping mapping, 80 HttpServletRequest request) { 81 ActionErrors aes = new ActionErrors(); 82 if(type!=TYPE_OWNER&&type!=TYPE_GENERAL&&type!=TYPE_COMMON) 83 aes.add("edit",new ActionError("category_type_not_accept")); 84 if(name!=null && StringUtils.isEmpty(name)) 85 aes.add("edit",new ActionError("not_empty_allow")); 86 return aes; 87 } 88 89 93 public String getIconUrl() { 94 return iconUrl; 95 } 96 97 101 public void setIconUrl(String iconUrl) { 102 if(!"".equals(iconUrl)) 103 this.iconUrl = iconUrl; 104 } 105 106 110 public int getType() { 111 return type; 112 } 113 114 public String getTypeDesc() { 115 switch(type) { 116 case TYPE_OWNER: 117 return "隐藏分类"; 118 case TYPE_GENERAL: 119 return "普通分类"; 120 case TYPE_COMMON: 121 return "开放分类"; 122 } 123 return null; 124 } 125 126 130 public void setType(int type) { 131 this.type = type; 132 } 133 134 138 public int getOrder() { 139 return order; 140 } 141 142 146 public void setOrder(int order) { 147 this.order = order; 148 } 149 150 154 public String getName() { 155 return name; 156 } 157 158 162 public void setName(String name) { 163 this.name = name; 164 } 165 166 170 public int getId() { 171 return id; 172 } 173 174 178 public void setId(int id) { 179 this.id = id; 180 } 181 182 185 public List getLogs() { 186 return logs; 187 } 188 189 192 public void setLogs(List list) { 193 logs = list; 194 } 195 196 199 public String toString() { 200 return name; 201 } 202 203 206 public SiteForm getSite() { 207 return site; 208 } 209 210 213 public void setSite(SiteForm form) { 214 site = form; 215 } 216 217 public int getLogCount() { 218 return logCount; 219 } 220 public void setLogCount(int logCount) { 221 this.logCount = logCount; 222 } 223 } 224 | Popular Tags |