Use of <s:selectItems> in JBoss Seam


In JSF (JavaServer Faces), the use of a SelectList or SelectMenu is combined with the use of a List<SelectItem> in a backing bean. Most of the times you already have a list wih the items to choose from, and have to rewrite that list to selectItems. And then add a way in your backing bean to set the selected item when the form is send. With JBoss Seam it’s completely coverered in the framework:


   
          

With only this in your JSF page, combined with a standard entity manager bean (extension of EntityHome class, part of the Seam apllication framework):

public class EHome extends EntityHome {
}

The <s:convertEntity /> automagically converts a standard list into a SelectItem list, and the does all the plumbing of setting the selected object in instance.var, according to the selected item from the SelectItem list.


Leave a Reply