📄 productsbodytag.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/ProductsBodyTag.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 java.util.Iterator;
import javax.servlet.jsp.PageContext;
import javax.sql.DataSource;
import com.hp.mw.samples.struts.storefront.dataaccess.DataMiddle;
import com.hp.mw.samples.struts.storefront.databeans.Product;
import com.hp.mw.samples.struts.storefront.datasources.ConfigurableDataSource;
/**
*
* @author <a href="mailto:zcollier@m7.com">Zaitrarrio Collier</a>
* @version $ Revision: $
*/
public class ProductsBodyTag
extends ArbitraryIteratorBodyTag
{
/**
* Default value for <code>serialVersionUID</code> required for Serializable class
*/
private static final long serialVersionUID = 1L;
private String dataMiddleId;
private int dataMiddleScope;
//~ Constructors -----------------------------------------------------------
public ProductsBodyTag( ) {
setDataMiddleScope(PageContext.APPLICATION_SCOPE);
}
/**
* @return
*/
public String getDataMiddleId() {
return dataMiddleId;
}
/**
* @return
*/
public int getDataMiddleScope() {
return dataMiddleScope;
}
/**
* @param string
*/
public void setDataMiddleId(String string) {
dataMiddleId = string;
}
/**
* @param i
*/
public void setDataMiddleScope(int i) {
dataMiddleScope = i;
}
/* (non-Javadoc)
* @see com.hp.mw.samples.struts.storefront.taglibs.ArbitraryIteratorBodyTag#getIterator()
*/
protected Iterator getIterator() throws Exception {
DataSource ds = ConfigurableDataSource.sInstance;
DataMiddle dba = (DataMiddle) pageContext.getAttribute(dataMiddleId, dataMiddleScope);
if (dba == null) {
dba = new DataMiddle();
dba.setDataSource(ds);
pageContext.setAttribute(dataMiddleId, dba, dataMiddleScope);
}
Collection products = new ArrayList();
String[] ids = new String[] { "91", "95", "92", "94", "93" };
for (int i = 0; i < ids.length; i++) {
Product prod = new Product();
prod.setProductId(ids[i]);
dba.find(prod);
products.add(prod);
}
return products.iterator();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -