O'Reilly logo

JSF 2.0 Cookbook by Anghel Leonard

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using custom converters for h:selectOneMenu

A common issue regarding JSF converters and the h:selectOneMenu component can be recreated in a simple scenario. Let's suppose that we are in the following situation: we have a database table that contains a number of rows that define cars. Each row has an Integer value representing the car number and a string value representing the car name. Obviously this table is wrapped into a managed bean, as shown next:

package cars; import javax.faces.bean.ManagedBean; @ManagedBean public class CarBean { private Integer carNumber; private String carName; public CarBean() {} public CarBean(Integer carNumber, String carName){ this.carNumber=carNumber; this.carName=carName; } public Integer getCarNumber(){ return ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required