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

📄 searchresultstag.java

📁 基于struts框架的web开发应用实例
💻 JAVA
字号:
/**
 *
 * $Header: /raid1/wide/cvsroot/wide/dev/struts/struts-metadata/templates/new-app/nitroX-tour/site/WEB-INF/src/java/com/hp/mw/samples/struts/storefront/taglibs/SearchResultsTag.java,v 1.1 2005/10/10 20:12:04 sami Exp $
 *
 * Copyright (c) 2002 by M7 Corporation
 * All rights reserved.
 *
 * The information contained herein is confidential and proprietary
 * to M7 Corporation, and considered a trade secret as defined under
 * civil and criminal statutes.  M7 Corporation shall pursue its
 * civil and criminal remedies in the event of unauthorized use or
 * misappropriation of its trade secrets.  Use of this information
 * by anyone other than authorized employees of M7 Corporation is
 * granted only under a written non-disclosure agreement, expressly
 * prescribing the scope and manner of such use.
 *
 */
package com.hp.mw.samples.struts.storefront.taglibs;

import java.util.ArrayList;
import java.util.Collection;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.PageContext;

import com.hp.mw.samples.struts.storefront.dataaccess.ProductSearch;


/**
 *
 * @author <a href="mailto:zcollier@m7.com">Zaitrarrio Collier</a>
 * @version $ Revision: $
 */
public class SearchResultsTag
    extends AbstractDefineObjectTag
{
  /**
    * Default value for <code>serialVersionUID</code> required for Serializable class
    */
   private static final long serialVersionUID = 1L;

	private String searchId;
	private int searchScope;
	
    //~ Constructors -----------------------------------------------------------

    public SearchResultsTag(  ) 
    { 
		setScope(PageContext.SESSION_SCOPE);
		setSearchScope(PageContext.SESSION_SCOPE);
    }

    //~ Methods ----------------------------------------------------------------

	/**
	 * @return
	 */
	public String getSearchId() {
		return searchId;
	}

	/**
	 * @param string
	 */
	public void setSearchId(String string) {
		searchId = string;
	}

	/**
	 * @return
	 */
	public int getSearchScope() {
		return searchScope;
	}

	/**
	 * @param i
	 */
	public void setSearchScope(int i) {
		searchScope = i;
	}

    protected Object getObject(  )
        throws java.lang.Exception
    {
        HttpServletRequest request = ( HttpServletRequest ) pageContext.getRequest(  );
        ProductSearch search = (ProductSearch)pageContext.getAttribute(searchId, getSearchScope());
        if (search == null) {
        	search = new ProductSearch();
        	pageContext.setAttribute(searchId, search, getSearchScope());
        }
		Collection results = null;
		String action = request.getParameter("action");
		action = action == null ? "" : action;
		if (action.equals("pageForward"))
		{
		  results = search.getNextPage();
		}
		else if (action.equals("pageBack"))
		{
		  results = search.getPreviousPage();
		}
		if (results == null)
		{
		  results = new ArrayList();
		}

		return results;
    }


}

⌨️ 快捷键说明

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