此系统为我大家完全开发一个相册管理系统

源代码在线查看: searchaction.java

软件大小: 15750 K
上传用户: zwaheron
关键词: 管理系统
下载地址: 免注册下载 普通下载 VIP

相关代码

				/* ====================================================================
				 * $Id$
				 * ====================================================================
				 *  文件名    SearchAction.java
				 *  机能名    
				 *  履历      2005-1-30 dlxu 创建新文件  
				 *           Copyright 2004 东南大学 All Rights Reserved
				 * ====================================================================
				 */
				package cn.edu.seu.album.web;
				
				import java.text.DateFormat;
				import java.text.SimpleDateFormat;
				import java.util.ArrayList;
				import java.util.Iterator;
				import java.util.List;
				
				import javax.servlet.http.HttpServletRequest;
				import javax.servlet.http.HttpServletResponse;
				
				import org.apache.log4j.Category;
				import org.apache.log4j.Logger;
				import org.apache.struts.action.ActionForward;
				import org.apache.struts.action.ActionMapping;
				import org.apache.struts.action.ActionMessages;
				
				import cn.edu.seu.album.common.PJAction;
				import cn.edu.seu.album.common.PJActionForm;
				import cn.edu.seu.album.common.PJBizBroker;
				import cn.edu.seu.album.common.PJConst;
				import cn.edu.seu.album.common.PJException;
				import cn.edu.seu.album.model.PictureListBean;
				import cn.edu.seu.album.model.SearchCondition;
				import cn.edu.seu.album.model.SearchRslt;
				import cn.edu.seu.album.pojo.Photo;
				
				/**
				 *  [概 要] 
				 *  [详 细] 
				 *  [备 考] 无。
				 *
				 * @author dlxu
				 * @version 1.0 2005-1-30
				 * @since 1.0
				 */
				public final class SearchAction extends PJAction {
				
				    /**
				     * 日志定义。
				     */
				    private static final Category log = Logger.getInstance(SearchAction.class);
				
				    /**
				     * 日期格式。
				     */
				    private static final DateFormat DF = new SimpleDateFormat("yyyy年MM月dd日HH时mm分ss秒");
				
				    /**
				     *  [概 要] 
				     *  [详 细] 
				     *  [备 考] 无。
				     * @param mapping
				     * @param aForm
				     * @param request
				     * @param response
				     * @param errs
				     * @return
				     * @throws PJException
				     * @see cn.edu.seu.album.common.PJAction#doAction(org.apache.struts.action.ActionMapping, cn.edu.seu.album.common.PJActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, org.apache.struts.action.ActionMessages)
				     */
				    protected ActionForward doAction(ActionMapping mapping, PJActionForm aForm,
				            HttpServletRequest request, HttpServletResponse response,
				            ActionMessages errs) throws PJException {
				        log.debug("doAction开始");
				        ActionForward af = mapping.getInputForward();
				
				        log.debug(aForm);
				
				        String actionType = aForm.getActionType();
				
				        SearchForm form = (SearchForm) aForm;
				
				        if (ACTION_INIT.equals(actionType)) {
				            doInit(form);
				        } else if (ACTION_SEARCH.equals(actionType)) {
				            doSearch(form, request, response, errs);
				        }
				
				        log.debug("doAction结束");
				        return af;
				    }
				
				    /**
				     *  [概 要] 
				     *  [详 细] 
				     *  [备 考] 无。
				     * @param form
				     * @param request
				     * @param response
				     * @param errs
				     */
				    private void doSearch(SearchForm form, HttpServletRequest request,
				            HttpServletResponse response, ActionMessages errs)
				            throws PJException {
				        log.debug("doSearch开始");
				
				        SearchCondition cond = new SearchCondition();
				
				        String fromYear = form.getFromYear();
				        String fromMonth = form.getFromMonth();
				        String fromDay = form.getFromDay();
				        String toYear = form.getToYear();
				        String toMonth = form.getToMonth();
				        String toDay = form.getToDay();
				        String owner = form.getOwner();
				        String sortField = form.getSortField();
				        String sortOrder = form.getSortOrder();
				
				        cond.setFromYear(fromYear);
				        cond.setFromMonth(fromMonth);
				        cond.setFromDay(fromDay);
				        cond.setToYear(toYear);
				        cond.setToMonth(toMonth);
				        cond.setToDay(toDay);
				        cond.setOwner(owner);
				        cond.setSortField(sortField);
				        cond.setSortOrder(sortOrder);
				
				        SearchRslt rslt = (SearchRslt) PJBizBroker.invoke("SearchBiz", cond,
				                errs, request);
				        if (rslt.isCheckOk()) {
				            List searchList = rslt.getPictureList();
				            List newList = new ArrayList();
				            PictureListBean picListBean = null;
				            for (Iterator iter = searchList.iterator(); iter.hasNext();) {
				                Photo photo = (Photo) iter.next();
				                picListBean = new PictureListBean();
				                picListBean.setPhoto(photo);
				
				                picListBean.setPictureId(photo.getId());
				                picListBean.setPictureName(photo.getName());
				                picListBean.setPicturePriv(photo.getPriv());
				                picListBean.setPicturePrivName(PJConst.getAttribute(photo
				                        .getPriv()));
				                picListBean.setLastModifyTime(DF.format(photo
				                        .getLastUpdateDate()));
				
				                newList.add(picListBean);
				            }
				
				            form.setRslt(rslt);
				            form.setPicList(newList);
				            form.setCanList(rslt.isCheckOk());
				        } else {
				            form.setPicList(new ArrayList());
				            form.setCanList(false);
				        }
				
				        log.debug("doSearch结束");
				
				    }
				
				    /**
				     *  [概 要] 
				     *  [详 细] 
				     *  [备 考] 无。
				     * @param form
				     */
				    private void doInit(SearchForm form) throws PJException {
				        log.debug("doInit开始");
				
				        //        Calendar cale = Calendar.getInstance();
				        //        int year = cale.get(Calendar.YEAR);
				        //        int month = cale.get(Calendar.MONTH);
				        //        int day = cale.get(Calendar.DATE);
				        //
				        //        form.setToYear(String.valueOf(year));
				        //        form.setToMonth(String.valueOf(month));
				        //        form.setToDay(String.valueOf(day));
				        String userName = form.getSessionBean().getPerson().getName();
				        form.setCanList(false);
				        form.setPicList(new ArrayList());
				        form.setOwner(userName);
				        log.debug("doInit结束");
				    }
				
				}			

相关资源