📄 topicform.java
字号:
package com.elan.forum.forms.topic;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import com.elan.forum.util.ElCheckString;
public class TopicForm extends ActionForm {
private String title;
private String author;
private Integer authorId;
private String text;
private String topicType;
private Integer pieceId;
private Integer topicId;
public Integer getAuthorId() {
return authorId;
}
public void setAuthorId(Integer authorId) {
this.authorId = authorId;
}
public Integer getTopicId() {
return topicId;
}
public void setTopicId(Integer topicId) {
this.topicId = topicId;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getAuthor() {
return author;
}
public void setAuthor(String author) {
this.author = author;
}
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
public String getTopicType() {
return topicType;
}
public void setTopicType(String actrileType) {
this.topicType = actrileType;
}
@Override
public ActionErrors validate(ActionMapping mapping,
HttpServletRequest request) {
String action = request.getParameter("action");
/*
* if 判断 是否需要CHECK
*/
if ("showPiece".equals(action)) {
return null;
}
if ("showTopic".equals(action)) {
return null;
}
if ("newForm".equals(action)) {
return null;
}
if ("replyForm".equals(action)) {
return null;
}
if("replyTopic".equals(action)) {
ActionErrors errors = new ActionErrors();
if (ElCheckString.isEmptyString(author)
|| authorId == null
|| authorId.intValue() < 1
|| ElCheckString.isEmptyString(text)
|| pieceId == null
|| topicId == null
|| pieceId.intValue() < 1
|| topicId.intValue() < 1) {
errors = new ActionErrors();
errors.add("error", new ActionError("post.topic.validate.err"));
}
if(null == request.getSession().getAttribute("user")) {
errors.add("error", new ActionError("user.not.login"));
}
System.out.println(title);
System.out.println(author);
System.out.println(text);
System.out.println(topicType);
//request.setAttribute("errors", errors);
return errors;
}
if ("newTopic".equals(action)) {
ActionErrors errors = null;
if (ElCheckString.isEmptyString(title)
|| ElCheckString.isEmptyString(author)
|| this.authorId == null
|| ElCheckString.isEmptyString(text)
|| ElCheckString.isEmptyString(topicType)
|| pieceId.intValue() < 1) {
errors = new ActionErrors();
errors.add("error", new ActionError("post.topic.validate.err"));
}
System.out.println("title:" + title);
System.out.println("author:" + author);
System.out.println("authorId:" + authorId);
System.out.println("text:" + text);
System.out.println("topicType:" + topicType);
return errors;
}
System.out.println("title:" + title);
System.out.println("author:" + author);
System.out.println("authorId:" + authorId);
System.out.println("text:" + text);
System.out.println("topicType:" + topicType);
return null;
}
public Integer getPieceId() {
return pieceId;
}
public void setPieceId(Integer pieceId) {
this.pieceId = pieceId;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -