/* * Here we must create our list of objects * obviously we may add a cycle "while" or "for" * if we wouldn't know the number of items */ public UIComponentBase getList(){
list=new UISelectMany(); SelectItem item = new SelectItem( "value", "Description" ); UISelectItem uiItem = new UISelectItem(); uiItem.setValue( item );
list.getChildren().add( uiItem );
return list; }
public void setList(UIComponentBase list){ this.list=(UISelectMany)list; }
public void actionListener(ActionEvent ev){
Object obj [] = list.getSelectedValues(); // obj is an array of string that contents the values of our selectItems }
}
JSP页面的代码如下:
<h:selectManyMenu binding="#{Manager.list}">
如果你想使用CheckBox or a ListBox仅仅在JSF文件中该变标签就可以了.如 <h:selectManyCheckBox> by either <h:selectManyListbox> or <h:selectManyCheckbox>, it is great!!
WRITTEN BY JOSE HERNAN VALDES MURGUIA. CBBA-BOLIVIA. Hitoriki in jsf's java's forum
This page was made fast and I hope dont be a nuisance to someboby 首先我们定义backbean来管理我们的 selectMany "list" : Manager demo.Manager request 现在Manager类应该有个 SelectMany object来管理信息;