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

📄 categorylistbean.java

📁 一个ssh结构组成 的BS开发
💻 JAVA
字号:
package cn.hxex.library.view.bean;

import java.util.ArrayList;
import java.util.List;

import javax.faces.model.SelectItem;

import cn.hxex.library.model.Category;

/**
 * 商品分类信息查询Bean
 * 
 * @author galaxy
 *
 */
public class CategoryListBean extends BaseBean
{
	//	list of all the category backing beans
	private List<CategoryBean> categoryBeans;

	/**
	 * @return Returns the categoryBeans.
	 */
	public List<CategoryBean> getCategoryBeans()
	{
		return categoryBeans;
	}

	/**
	 * @param categoryBeans The categoryBeans to set.
	 */
	public void setCategoryBeans(List<CategoryBean> categoryBeans)
	{
		this.categoryBeans = categoryBeans;
	}
	
	public CategoryListBean()
	{
		this.categoryBeans = new ArrayList<CategoryBean>();
	}
	
	protected void init()
	{
		List list = this.getServiceLocator().getCategoryService().getAllCategorys();
		this.categoryBeans.clear();
		for( int i=0; i<list.size(); i++ )
		{
			Category category = (Category)list.get( i );
			
			CategoryBean categoryBean = new CategoryBean();
			categoryBean.setServiceLocator( this.getServiceLocator() );
			
			CategoryBean.converToCategoryBean( categoryBean, category );
			this.categoryBeans.add( categoryBean );
		}
		list = null;
	}
	
	/**
	 * Backing bean list all categories
	 * 
	 * @return
	 */
	public String listAction()
	{
		this.logger.info( "Catalog listAction is invoked!" );

		return NavigationResults.CATEGORY_LIST;
	}
	
	public SelectItem[] getCategoryItems()
	{
		SelectItem[] items = new SelectItem[this.getCategoryBeans().size()];
		for( int i=0; i<this.getCategoryBeans().size(); i++ )
		{
			CategoryBean categoryBean = this.getCategoryBeans().get( i );
			items[i] = new SelectItem( categoryBean.getId(), categoryBean.getName() );
		}
		return items;
	}
}

⌨️ 快捷键说明

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