replytopicform.java

来自「struts+hibernate BBS mysql数据库 功能基本齐全」· Java 代码 · 共 70 行

JAVA
70
字号
package com.elan.forum.forms;

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;

public class ReplyTopicForm extends ActionForm {
	private Integer topicId;
	private Integer authorId;
	private String author;
	private String text;

	public Integer getTopicId() {
		return topicId;
	}

	public void setTopicId(Integer topicId) {
		this.topicId = topicId;
	}

	public Integer getAuthorId() {
		return authorId;
	}

	public void setAuthorId(Integer authorId) {
		this.authorId = authorId;
	}

	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;
	}

	@Override
	public void reset(ActionMapping mapping, HttpServletRequest request) {
		this.text = "";
	}

	@Override
	public ActionErrors validate(ActionMapping mapping,
			HttpServletRequest request) {
		System.out.println(authorId);
		System.out.println(author);
		System.out.println(text);
		System.out.println(topicId);
		ActionErrors errors = new ActionErrors();
		if ("".equals(this.text)
				|| (this.authorId != null && this.authorId.intValue() < 1)
				|| (this.author != null && "".equals(this.author.trim()))
				|| (this.topicId != null && this.topicId.intValue() < 1)) {
			errors.add("", new ActionError("forum.topic.reply.text.requried"));
		}
		return errors;
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?