⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 viewthreadaction.java

📁 Chinaxp 论坛源代码
💻 JAVA
字号:
/* * XP Forum * * Copyright (c) 2002-2003 RedSoft Group.  All rights reserved. * */package org.redsoft.forum.web;import java.io.IOException;import java.util.ArrayList;import java.util.Collection;import java.util.Iterator;import javax.servlet.ServletException;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import org.apache.struts.action.Action;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.redsoft.forum.ForumConstants;import org.redsoft.forum.dao.DAOFactory;import org.redsoft.forum.dao.ThreadDAO;import org.redsoft.forum.exception.DAOException;import org.redsoft.forum.exception.ThreadNotFoundException;/** * View all the threads * * @author <a href="mailto:jwtronics@yahoo.com">John Wong</a> * * @version $Id: ViewThreadAction.java,v 1.5 2004/04/10 19:57:01 cinc Exp $ */public class ViewThreadAction extends Action {    public ActionForward execute(ActionMapping mapping,				 ActionForm form,				 HttpServletRequest request,				 HttpServletResponse response)	throws IOException, ServletException {		ActionErrors errors = new ActionErrors();		final ThreadDAO dao = DAOFactory.getInstance().getThreadDAO();		// If there are selected records for remove,remove selected threads		final String[] seletedThreads = request.getParameterValues( "remove" );		if( seletedThreads != null && seletedThreads.length > 0 ){			try{				for( int index = 0; index < seletedThreads.length; index++ ){					dao.removeThread( Long.parseLong( seletedThreads[ index ] )  );				}			} catch (DAOException daoe) {                daoe.printStackTrace();                return (mapping.findForward("error"));            }		}		final String parentId = request.getParameter(ForumConstants.PARENT_ID_PARAM);		if(parentId == null || parentId.equals("")) {			errors.add(ActionErrors.GLOBAL_ERROR,                           new ActionError("error.parentId.invalid"));		}       	long id = Long.parseLong(parentId);		try {			// update the click count			dao.updateClick(id);			Collection pts = dao.findByParnetID(id);			Collection threads = new ArrayList(pts.size());			Iterator itr = pts.iterator();			while(itr.hasNext()) {				threads.add( itr.next() );			}			request.setAttribute(ForumConstants.THREADS_COLLECTION_KEY, threads);		} catch (ThreadNotFoundException tnfe) {			System.out.println("Thread not found " + tnfe.getMessage() );			return (mapping.findForward("error"));		} catch (DAOException daoe) {            daoe.printStackTrace();            return (mapping.findForward("error"));        }        // Report any errors we have discovered back to the original form		if (!errors.isEmpty()) {			saveErrors(request, errors);		}        // Forward control to the specified success URI		return (mapping.findForward("success"));	}}

⌨️ 快捷键说明

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