KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > dlog4j > formbean > LogForm


1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 2 of the License, or
5  * (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU Library General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software
14  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
15  */

16 package dlog4j.formbean;
17
18 import java.util.ArrayList JavaDoc;
19 import java.util.Date JavaDoc;
20 import java.util.List JavaDoc;
21 import java.util.StringTokenizer JavaDoc;
22
23 import javax.servlet.http.HttpServletRequest JavaDoc;
24
25 import org.apache.struts.action.ActionError;
26 import org.apache.struts.action.ActionErrors;
27 import org.apache.struts.action.ActionMapping;
28
29 /**
30  * 日志
31  * @auhor Liudong
32  */

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 JavaDoc searchKey;
41     int viewCount;
42     int replyCount;
43     List JavaDoc replies;
44     List JavaDoc trackBacks;
45     Date JavaDoc deleteTime;
46     int replyNotify = 0;
47     int status = STATUS_NORMAL;
48
49     /* 用户输入的验证
50      * @see org.apache.struts.action.ActionForm#validate(org.apache.struts.action.ActionMapping, javax.servlet.ServletRequest)
51      */

52     public ActionErrors validate(ActionMapping arg0, HttpServletRequest JavaDoc 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 JavaDoc getSearchKey() {
68         return searchKey;
69     }
70     public String JavaDoc[] getSearchKeys(){
71         if(searchKey==null)
72             return null;
73         ArrayList JavaDoc keys = new ArrayList JavaDoc();
74         StringTokenizer JavaDoc st = new StringTokenizer JavaDoc(searchKey);
75         while(st.hasMoreElements()){
76             keys.add(st.nextToken());
77         }
78         return (String JavaDoc[])keys.toArray(new String JavaDoc[keys.size()]);
79     }
80     public void setSearchKey(String JavaDoc 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     /**
95      * @return
96      */

97     public CategoryForm getCategory() {
98         return category;
99     }
100
101
102     /**
103      * @return
104      */

105     public List JavaDoc getReplies() {
106         return replies;
107     }
108
109     /**
110      * @return
111      */

112     public int getReplyCount() {
113         return replyCount;
114     }
115
116     /**
117      * @return
118      */

119     public int getViewCount() {
120         return viewCount;
121     }
122
123     /**
124      * @param form
125      */

126     public void setCategory(CategoryForm form) {
127         category = form;
128     }
129
130     /**
131      * @param list
132      */

133     public void setReplies(List JavaDoc list) {
134         replies = list;
135     }
136
137     /**
138      * @param i
139      */

140     public void setReplyCount(int i) {
141         replyCount = i;
142     }
143
144     /**
145      * @param i
146      */

147     public void setViewCount(int i) {
148         viewCount = i;
149     }
150
151     /**
152      * @return
153      */

154     public int getStatus() {
155         return status;
156     }
157
158     /**
159      * @param i
160      */

161     public void setStatus(int i) {
162         status = i;
163     }
164     public List JavaDoc getTrackBacks() {
165         return trackBacks;
166     }
167     public void setTrackBacks(List JavaDoc trackBacks) {
168         this.trackBacks = trackBacks;
169     }
170     public Date JavaDoc getDeleteTime() {
171         return deleteTime;
172     }
173     public void setDeleteTime(Date JavaDoc 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