Introduction

Easy SelectItems is an extended version of javax.faces.component.UISelectItems. By using the component there is no need to manually create a SelectItem collection because EasySI automatically populates SelectItem objects from types like Collection, Map and etc.

Dependencies

EasySI has no dependency other than a JSF implementation. Although MyFaces is used during development process, the component is also compatible with RI or Trinidad.

Online Demo

You can check out the features and try it at via the online demo

Usage

classpath

Place the easysi-*.*.*.jar to your application's lib folder.

page

Taglib Definition to be added top of the jsf page.

<%@taglib uri="http://sourceforge.net/projects/easysi" prefix="s" %>
				

example

Both java and jsp code.

The getter in the backing bean;

public List getPlayers() { 
	List list = new ArrayList(); 
	Player player1 = new Player("Roni", new Integer(10)); 
	Player player2 = new Player("Eto'o", new Integer(9)); 
	Player player3 = new Player("Messi", new Integer(19)); 
	Player player4 = new Player("Deco", new Integer(20));	
	list.add(player1); 
	list.add(player2);
	list.add(player3); 
	list.add(player4); 
return list; 
}
					

The code in the jsp;

<h:selectOneMenu id="menu1" value="#{EasysiDemo.selectedPlayerNo}">
	<s:selectItems value="#{EasysiDemo.players}" var="Player" itemLabel="#{Player.name}" itemValue="#{Player.no}"/>
</h:selectOneMenu>
				

Output

<select id="form1:menu1" name="form1:menu1" size="1"> 
	<option value="10">Ronaldinho</option>
	<option value="9">Eto'o</option>
	<option value="19">Messi</option>
	<option value="20">Deco</option>
</select>
				

Attributes and Possible Values

Other than the original attributes (id and binding), this extended version brings some extra attributes.

var
Name of the iterator
itemLabel
Label to be displayed to the user for selection.
itemValue
Value of the label.

Authors

Cagatay Civici

JRoller Blog

Mert Caliskan

JRoller Blog