亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? topicaction.java

?? struts+hibernate BBS mysql數(shù)據(jù)庫 功能基本齊全
?? JAVA
?? 第 1 頁 / 共 2 頁
字號:
package com.elan.forum.actions.topic;

import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
import org.apache.struts.action.ActionMessages;

import com.elan.forum.elf.El;
import com.elan.forum.forms.ReplyTopicForm;
import com.elan.forum.forms.topic.TopicForm;
import com.elan.forum.model.ForumTopic;
import com.elan.forum.model.ForumUser;
import com.elan.forum.model.Forummodule;
import com.elan.forum.model.Forumpiece;
import com.elan.forum.model.Forumtopicreply;
import com.elan.forum.util.Constents;

/**
 * @author Elan
 * 
 */
public class TopicAction extends TopicBaseAction {

	@Override
	protected ActionForward newTopic(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		Integer authorId = null;
		String title = null;
		String author = null;
		String text = null;
		String topicType = null;
		Integer pieceId = -1;
		String forwardUrl = request.getContextPath() + "/forum/Test.jsp";
		if (form != null) {
			authorId = ((TopicForm) form).getAuthorId();
			title = ((TopicForm) form).getTitle();
			author = ((TopicForm) form).getAuthor();
			text = ((TopicForm) form).getText();
			topicType = ((TopicForm) form).getTopicType();
			pieceId = ((TopicForm) form).getPieceId();
		}

		// 待寫代碼,重新初始化構(gòu)造函數(shù)
		// 是一個(gè)榮譽(yù)的字段,,,需要刪除
		Forumpiece fp = El.getEl().getPieceMgr().getForumPieceById(pieceId);
		ForumUser fu = El.getEl().getForumUserMgr().findUserById(authorId);
		if (fu == null) {
			System.out.println("fu is null");
		}
		// 實(shí)例化一個(gè)topic對象,等待持久化
		ForumTopic topic = new ForumTopic(1, fp, fu, title, author, text,
				"topicType", "0.gif", 0, 0, new Timestamp(System
						.currentTimeMillis()), new Timestamp(System
						.currentTimeMillis()), Byte.valueOf("0"), Byte
						.valueOf("0"), Byte.valueOf("0"), Byte.valueOf("0"),
				"moduleName", "pieceName", Byte.valueOf("0"),
				Byte.valueOf("0"), Byte.valueOf("0"));
		// //
		if (1 != El.getEl().getTopicMgr().postTopic(topic)) {
			ActionErrors errors = new ActionErrors();
			errors.add("posttopicerr", new ActionMessage("post.topic.error"));
			saveErrors(request, errors);
			return (new ActionForward("ForumError"));
		}
		forwardUrl = request.getContextPath()
				+ "/forum/topic.do?action=showTopic&topicId=" + topic.getId();
		ActionMessages msgs = new ActionMessages();
		msgs.add("messages", new ActionMessage("post.topic.success"));
		request.setAttribute("messages", msgs);
		request.setAttribute("forwardUrl", forwardUrl);
		// 構(gòu)造路徑
		String position = constructPosition(request, pieceId, (topic)
				.getPiece().getName(), topic.getId(), topic.getTitle());
		request.setAttribute("position", position);
		System.out.println(position);

		com.elan.forum.util.Constents.addTopicNum();// 貼數(shù)加

		// 修改piece中的isNewTopic字段為1,hibernate練級操作
		topic.getPiece().setIsNewTopic(true);

		return mapping.findForward("postTopicSuccess");
	}

	@Override
	protected ActionForward newForm(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		Integer pieceId = getPieceId(request);
		Forumpiece fp = El.getEl().getPieceMgr().getForumPieceById(pieceId);
		// 構(gòu)造位置
		String position = constructPosition(request, fp.getId(), fp.getName(),
				null, null);
		request.setAttribute("position", position);
		System.out.println("已經(jīng)進(jìn)入到這里了");
		return mapping.findForward("newForm");
	}

	/*
	 * 1)分頁 2)是否有新的回復(fù)
	 * 
	 * (non-Javadoc)
	 * 
	 * @see com.elan.forum.actions.topic.TopicBaseAction#showPiece(org.apache.struts.action.ActionMapping,
	 *      org.apache.struts.action.ActionForm,
	 *      javax.servlet.http.HttpServletRequest,
	 *      javax.servlet.http.HttpServletResponse)
	 */
	@Override
	protected ActionForward showPiece(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		// System.out.println("in showPiece >>");
		// mapping.setValidate(false);

		Integer pieceId = this.getPieceId(request);
		// 獲取精華帖子
		List<ForumTopic> listEssenceTopic = El.getEl().getTopicMgr()
				.getEssenceTopic(pieceId);
		// 獲取回復(fù)size(reply) == size(EssenceTopic)
		List<String> listEssenceTopicReply = new ArrayList<String>();
		int intEssenceTopicReply = 0;
		for (intEssenceTopicReply = 0; listEssenceTopic != null
				&& intEssenceTopicReply < listEssenceTopic.size(); intEssenceTopicReply++) {
			Forumtopicreply ftr = El.getEl().getTopicMgr()
					.getLastTopicReplyById(
							((ForumTopic) listEssenceTopic
									.get(intEssenceTopicReply)).getId());
			if (ftr != null) {
				listEssenceTopicReply.add(ftr.getReplyTime() + "<br>by:"
						+ ftr.getAuthor());
			} else {
				listEssenceTopicReply
						.add("<font color='red'>無</font> <br>by <font color='red'>無</font>");
			}
		}
		if (intEssenceTopicReply != 0) {
			this.setAttribute(request, "listEssenceTopicReply",
					listEssenceTopicReply);
			this.setAttribute(request, "listEssenceTopic", listEssenceTopic);
		}

		// 獲取固定的帖子 有可能返回的是空的
		List<ForumTopic> listTopTopic = El.getEl().getTopicMgr().getTopTopic(
				pieceId);
		// 獲取最后回復(fù),它的size與listTopTopic的size是一樣的大小的
		List<String> lastTopTopicReply = new ArrayList<String>();
		int tempI = 0;
		for (tempI = 0; listTopTopic != null && tempI < listTopTopic.size(); tempI++) {
			Forumtopicreply ftr = El.getEl().getTopicMgr()
					.getLastTopicReplyById(
							((ForumTopic) listTopTopic.get(tempI)).getId());
			if (ftr != null) {
				lastTopTopicReply.add(ftr.getReplyTime() + "<br>by:"
						+ ftr.getAuthor());
			} else {
				lastTopTopicReply
						.add("<font color='red'>無</font> <br>by <font color='red'>無</font>");
			}
		}
		if (tempI != 0) {
			this.setAttribute(request, "lastTopTopicReply", lastTopTopicReply);
			this.setAttribute(request, "listTopTopic", listTopTopic);
		}

		Map map = new HashMap();

		// 總的TOPIC數(shù)
		Long topicCount = new Long(0);

		// 總頁數(shù)
		Long pageCount = new Long(0);
		// 頁數(shù)大小
		Integer pageSize = Constents.piecePageSize;
		// 當(dāng)前頁碼
		Integer page = this.getPage(request);
		// 是否有新的回復(fù)
		Boolean[] isNewReplyArray = null;

		// 獲取MAP
		map = El.getEl().getTopicMgr().getForumPieceTopic(page, pageSize,
				pieceId);
		// 獲取pageCount 總的頁數(shù)
		pageCount = (Long) map.get("pageCount");
		// MAP中的topicCount
		topicCount = (Long) map.get("topicCount");
		// ..page
		page = (Integer) map.get("page");
		// .....
		List<String> lastReply = new ArrayList<String>();
		// 獲取是對應(yīng)于list中否有新的回復(fù)
		isNewReplyArray = (Boolean[]) map.get("isNewReplyArray");
		// 獲取全部
		// List<ForumTopic> list = El.getEl().getTopicMgr().findPiece(pieceId);

		// 獲取部分(分頁)
		List<ForumTopic> list = (List<ForumTopic>) map.get("list");
		if (list != null && list.size() > 0) {
			String position = constructPosition(request, pieceId,
					((ForumTopic) list.get(0)).getPiece().getName(), null, null);
			setAttribute(request, "position", position);
			setAttribute(request, "piece", list);
			setAttribute(request, "topicCount", topicCount);
			setAttribute(request, "pageSize", pageSize);
			setAttribute(request, "pageCount", pageCount);
			setAttribute(request, "page", page);
			setAttribute(request, "pieceId", pieceId);
			setAttribute(request, "isNewReplyArray", isNewReplyArray);
			// 獲取最后回復(fù)
			for (int i = 0; i < list.size(); i++) {
				Forumtopicreply ftr = El.getEl().getTopicMgr()
						.getLastTopicReplyById(
								((ForumTopic) list.get(i)).getId());
				if (ftr != null) {
					lastReply.add(ftr.getReplyTime() + "<br>by:"
							+ ftr.getAuthor());
				} else {
					lastReply
							.add("<font color='red'>無</font> <br>by <font color='red'>無</font>");
				}
			}
			this.setAttribute(request, "lastReply", lastReply);

		} else {
			// 找不到任何文章的piece
			ActionMessages messages = new ActionMessages();
			messages.add("", new ActionMessage("piece.no.topic"));
			saveMessages(request, messages);
		}

		return mapping.findForward("showPiece");
	}

	/*
	 * 
	 * 獲取帖子 (non-Javadoc)
	 * 
	 * @see com.elan.forum.actions.topic.TopicBaseAction#showTopic(org.apache.struts.action.ActionMapping,
	 *      org.apache.struts.action.ActionForm,
	 *      javax.servlet.http.HttpServletRequest,
	 *      javax.servlet.http.HttpServletResponse)
	 */
	@Override
	protected ActionForward showTopic(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {

		Map map = new HashMap();

		// topicId
		// 總的TOPIC回復(fù)數(shù)
		Long topicCount = new Long(0);

		// 總頁數(shù)
		Long pageCount = new Long(0);
		// 獲取設(shè)置回復(fù)頁數(shù)的大小
		Integer pageSize = Constents.topicReplyPageSize;
		// 當(dāng)前頁碼
		Integer page = this.getPage(request);
		// 是否有新的回復(fù)
		// ////////////////

		Integer topicId = getTopicId(request);
		System.out.println("TOpicId:..........................:" + topicId);
		//System.exit(0);
		ForumTopic fa = El.getEl().getTopicMgr().findPieceTopic(topicId);
		// 找不到該topic文章
		if (fa == null) {
			ActionErrors errors = new ActionErrors();
			errors.add("", new ActionError("topic.no.find"));
			saveErrors(request, errors);
			return mapping.findForward("topicNotFind");
		}
		// +TOPIC點(diǎn)擊
		fa.setClick(fa.getClick() + 1);
		El.getEl().getTopicMgr().saveTopic(fa);

		// 獲取有發(fā)TOPIC相互對應(yīng)的作者
		ForumUser topicAuthor = fa.getForumUser();

		// 構(gòu)造位置
		String position = constructPosition(request, fa.getPiece().getId(), fa
				.getPiece().getName(), fa.getId(), fa.getTitle());
		request.setAttribute("position", position);

		// 獲取map數(shù)據(jù)結(jié)構(gòu)
		map = El.getEl().getTopicMgr().getForumTopicReply(page, pageSize,
				topicId);
		// ...pageCount
		pageCount = (Long) map.get("pageCount");
		// ..topicCount
		topicCount = (Long) map.get("topicCount");
		// ..page ..重新復(fù)制,以防轉(zhuǎn)過的PAGE大與實(shí)際數(shù)據(jù)中的page
		page = (Integer) map.get("page");
		// 獲取回復(fù)
		List<Forumtopicreply> replyList = (List<Forumtopicreply>) map
				.get("replyList");
		// List<Forumtopicreply> falist =
		// El.getEl().getTopicMgr().findTopicReply(
		// topicId);
		// 獲取回復(fù)的作者
		List<ForumUser> replyUserList = new ArrayList<ForumUser>();
		for (int i = 0; i < replyList.size(); i++) {
			Forumtopicreply ftr = replyList.get(i);
			replyUserList.add(ftr.getForumUser());
		}

		this.setAttribute(request, "topicAuthor", topicAuthor);
		this.setAttribute(request, "replyList", replyList);
		this.setAttribute(request, "replyUserList", replyUserList);
		this.setAttribute(request, "topic", fa);
		this.setAttribute(request, "pieceId", fa.getPiece().getId());
		this.setAttribute(request, "topicId", topicId);

		this.setAttribute(request, "pageSize", pageSize);
		this.setAttribute(request, "topicCount", topicCount);
		this.setAttribute(request, "pageCount", pageCount);
		this.setAttribute(request, "page", page);
		
		return mapping.findForward("showTopic");
	}

	/*
	 * 跳到回復(fù)表單頁面 (non-Javadoc)
	 * 
	 * @see com.elan.forum.actions.topic.TopicBaseAction#replyForm(org.apache.struts.action.ActionMapping,
	 *      org.apache.struts.action.ActionForm,
	 *      javax.servlet.http.HttpServletRequest,
	 *      javax.servlet.http.HttpServletResponse)
	 */
	@Override
	protected ActionForward replyForm(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		//Integer pieceId = Integer.valueOf(request.getParameter("pieceId"));
		Integer topicId = Integer.valueOf(request.getParameter("topicId"));
		ForumTopic ft = El.getEl().getTopicMgr().findPieceTopic(topicId);

		// 構(gòu)造位置
		String position = constructPosition(request, ft.getPiece().getId(), ft
				.getPiece().getName(), ft.getId(), ft.getTitle());
		request.setAttribute("position", position);
		return mapping.findForward("replyForm");
	}

	/*
	 * Action:回復(fù)帖子 (non-Javadoc)
	 * 
	 * @see com.elan.forum.actions.topic.TopicBaseAction#replyTopic(org.apache.struts.action.ActionMapping,
	 *      org.apache.struts.action.ActionForm,
	 *      javax.servlet.http.HttpServletRequest,
	 *      javax.servlet.http.HttpServletResponse)
	 */
	@Override
	protected ActionForward replyTopic(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		byte locked = 0;
		Integer pieceId = 1;
		Integer topicId = 1;
		Integer authorId = this.getAuthorId(request);
		String text = null;
		String author = null;

		ForumUser fu = El.getEl().getForumUserMgr().findUserById(authorId);
		Forumtopicreply forumtopicreply = new Forumtopicreply();
		if (form != null) {
			topicId = ((TopicForm) form).getTopicId();
			text = ((TopicForm) form).getText();
			author = ((TopicForm) form).getAuthor();
			pieceId = ((TopicForm) form).getPieceId();
		}
		forumtopicreply.setTopicId(topicId);
		forumtopicreply.setForumUser(fu);
		forumtopicreply.setText(text);
		forumtopicreply.setAuthor(author);
		forumtopicreply.setIcon("3.gif");
		forumtopicreply.setReplyTime(new Timestamp(System.currentTimeMillis()));

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩二区在线观看| 在线观看成人免费视频| 国产精品一区二区久激情瑜伽| 免费欧美在线视频| 国产精品综合二区| av成人老司机| 欧美色电影在线| 精品免费一区二区三区| 久久久精品黄色| 中文字幕在线一区免费| 亚洲午夜精品网| 国产一区二区网址| 欧美主播一区二区三区美女| 日韩精品中午字幕| 亚洲精品免费看| 麻豆久久一区二区| 色婷婷精品久久二区二区蜜臀av| 91精品国产综合久久久久久漫画| 国产欧美日韩麻豆91| 一区二区免费在线播放| 国产伦精品一区二区三区免费 | 成人激情小说乱人伦| 欧美一二三区在线| 欧美激情一区在线观看| 香港成人在线视频| 粉嫩一区二区三区性色av| 欧美精品丝袜久久久中文字幕| 国产精品女同互慰在线看| 日韩精品一二三区| 欧美在线视频日韩| 中文一区二区完整视频在线观看| 日韩限制级电影在线观看| 69堂亚洲精品首页| 亚洲婷婷综合久久一本伊一区| 久久99精品久久久久久动态图| 色www精品视频在线观看| 久久久久久久久久电影| 奇米影视一区二区三区| 欧美精品黑人性xxxx| 亚洲精品日日夜夜| 91在线云播放| 亚洲免费观看高清完整版在线观看| 国产不卡在线视频| 中文字幕第一区| 成av人片一区二区| 欧美国产乱子伦| 成人动漫中文字幕| 一区二区三区在线免费| 在线免费亚洲电影| 亚洲成在人线免费| 日韩一区二区三| 日韩av一区二| 久久蜜桃av一区精品变态类天堂| 黄色日韩三级电影| 欧美国产精品v| 色婷婷精品大视频在线蜜桃视频 | 亚洲欧美一区二区不卡| 色狠狠一区二区| 日本不卡在线视频| 国产无一区二区| 欧美最猛性xxxxx直播| 五月婷婷另类国产| 欧美高清在线一区| 91蜜桃视频在线| 日本视频在线一区| 国产网站一区二区| 日韩欧美一级二级三级| 国内偷窥港台综合视频在线播放| 国产农村妇女毛片精品久久麻豆 | 国产成人精品亚洲777人妖| 亚洲视频一区二区免费在线观看 | 国产精品性做久久久久久| 亚洲欧美中日韩| 精品国产一区二区在线观看| 99国产精品久久久| 免费人成网站在线观看欧美高清| 国产精品夫妻自拍| 久久香蕉国产线看观看99| 欧美日韩在线播| av一区二区久久| 国产乱码精品一区二区三| 亚洲一区二区精品视频| 国产精品国产成人国产三级| 欧美一区二区高清| 欧美日韩激情在线| 色综合天天综合色综合av| 精品写真视频在线观看| 亚洲va在线va天堂| 一卡二卡三卡日韩欧美| 一区二区三区在线观看网站| 中文字幕国产精品一区二区| 久久日韩粉嫩一区二区三区| 欧美一区二区三区思思人| 欧美片在线播放| 欧美日韩一本到| 欧美日韩在线观看一区二区| 色婷婷精品大在线视频| 色香蕉成人二区免费| 不卡av在线免费观看| 91在线播放网址| 一本色道久久综合亚洲91| 色综合久久久久综合体桃花网| 91免费精品国自产拍在线不卡| 99精品视频中文字幕| 欧美日韩亚洲国产综合| 在线看国产一区| 欧美二区在线观看| 日韩欧美色综合网站| 成人av网在线| 国产一区在线不卡| 精品一区二区三区免费观看| 久久不见久久见免费视频7| 久久国产麻豆精品| eeuss鲁片一区二区三区| 色综合久久久网| 这里是久久伊人| 久久九九影视网| 成人欧美一区二区三区黑人麻豆| 亚洲图片欧美激情| 五月天一区二区三区| 国产成人综合网| 色香色香欲天天天影视综合网| 91精品国产欧美一区二区成人| 精品成a人在线观看| 一区二区视频在线看| 久久超碰97人人做人人爱| 99国产精品99久久久久久| 欧美日韩一区视频| 中文字幕不卡在线播放| 蜜臀久久99精品久久久久久9| 成人美女在线观看| 日韩一级黄色片| 一区二区三区在线观看欧美| 韩国三级在线一区| 精品视频免费看| 亚洲人成网站精品片在线观看| 国产一区日韩二区欧美三区| 欧美视频精品在线| 亚洲精品自拍动漫在线| 国产一区二区在线视频| 欧美电影一区二区| 亚洲国产成人av| 色综合久久久网| 中文字幕一区二区三区色视频| 视频一区二区国产| 欧美日韩久久久久久| 亚洲精品福利视频网站| 99久久精品国产导航| 久久久久久久综合狠狠综合| 日产国产高清一区二区三区| 欧美在线观看18| 一区二区三区欧美| 欧美亚洲一区二区在线观看| 亚洲日本韩国一区| 91在线国产观看| 亚洲免费毛片网站| 欧美亚洲日本国产| 日日夜夜精品免费视频| 欧美精品色一区二区三区| 亚洲一区日韩精品中文字幕| 欧美性色黄大片手机版| 天天免费综合色| 久久久亚洲综合| 成人av影视在线观看| 亚洲人成伊人成综合网小说| 成人av电影在线网| 亚洲国产日韩a在线播放性色| 在线精品亚洲一区二区不卡| 亚洲精品高清在线观看| 欧美久久一区二区| 国产露脸91国语对白| 综合激情成人伊人| 欧美日韩一区二区三区在线| 免费看欧美女人艹b| 久久精品人人爽人人爽| 色婷婷综合五月| 日本中文在线一区| 国产精品国产自产拍高清av王其| 一本色道a无线码一区v| 麻豆极品一区二区三区| 亚洲欧洲韩国日本视频| 日韩欧美第一区| 色88888久久久久久影院野外 | 欧美久久久一区| 国产黄人亚洲片| 午夜视频一区二区三区| 国产精品久久久久一区二区三区共 | 韩国精品免费视频| 亚洲国产成人av| 国产精品沙发午睡系列990531| 欧美日韩高清不卡| 成人av高清在线| 国产一区二区视频在线播放| 亚洲精品欧美激情| 国产精品少妇自拍| 亚洲国产高清在线观看视频| 精品人伦一区二区色婷婷| 欧美日韩中文字幕一区二区| 99精品视频中文字幕| 成人av免费在线播放|