combolistboxbean.java

来自「IBM RSA下的JSF开发示例」· Java 代码 · 共 63 行

JAVA
63
字号
/* ComboListBoxBean.java
 * Created on Dec 15, 2004
 *
 * A Bean used to store the values used to populate combo and list boxes.
 */
package com.ibm.samples.comboListBox;

import javax.faces.model.SelectItem;
import java.util.ArrayList;
import java.util.Collection;

/**
 * @author cmjaun
 */
public class ComboListBoxBean {
	
	private ArrayList months; // A Collection to hold SelectItem Objects
	private String[] shapes; // An array to hold String values.
	
	/**
	 * @return Returns the Collection of SelectItem Objects to populate Month List Box.
	 */
	public Collection getMonths() {
		// create and fill an ArrayList
		if(this.months == null) {
		months = new ArrayList();
		//the value and label are created in a new SelectItem object
		months.add(new SelectItem("Jan", "January"));
		months.add(new SelectItem("Feb", "February"));
		months.add(new SelectItem("Mar", "March"));
		months.add(new SelectItem("Apr", "April"));
		months.add(new SelectItem("May", "May"));
		months.add(new SelectItem("Jun", "June"));
		months.add(new SelectItem("Jul", "July"));
		months.add(new SelectItem("Aug", "August"));
		months.add(new SelectItem("Sep", "September"));
		months.add(new SelectItem("Oct", "October"));
		months.add(new SelectItem("Nov", "November"));
		months.add(new SelectItem("Dec", "December"));
		}
		return months;
	}
	/**
	 * @param items The items to set.
	 */
	public void setMonths(Collection months) {
		this.months = new ArrayList(months);
	}
	public String[] getShapes() {
		// create and fill the array of shapes
		if(this.shapes == null){
			shapes = new String[3];
			shapes[0] = "circle";
			shapes[1] = "triangle";
			shapes[2] = "square";
		}
		return shapes;
	}
	public void setShapes(String[] shapes){
		this.shapes = shapes;
	}
}

⌨️ 快捷键说明

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