ould sid'ahmed wrote:
Elenh Tsigka a écrit :
Hi,
In my jsf page, I use a h:selectOneMenu which contains a
f:selectItems. The attribute value of the selectItems element is a
list which is populated from a backing bean. The jsf snippet is like
this:
<h:selectOneMenu id="selectList" value="#{backingBean.selectedHotel}">
<f:selectItems value="#{backingBean.selectionList}"
rendered="#{backingBean.selectionList != null}"/>
</h:selectOneMenu>
My problem is that I want to associate an object (Hotel, which has
many metadata) with this selectionList. The drop down list will show
the name (String) of the Hotel, but when selecting an item from the
list I want to get a reference to the appropriate object (Hotel).
In my backingBean I have
selectionList = new ArrayList(); Which is populated through a
for loop like this:
selectionList.add(new SelectItem(Hotel));
I get an error indicating that I have to use a converter, as the
SelectItem isn't a String.
Is there an alternative to using a converter?
Isn't there a similar mechanism to this used by the datatable, which
is bind to a set of objects?
Hello,
I had this problem, you must use a Map, Collection or SelectItems with
the place an ArrayList
Good luck.
Hi,
Thanx for the reply.
But it doesn't make any difference.
The thing is that I populate the list assigned to the value attribute of
selectItems with a objects of non primitive type, I guess. Because if I
use :
selectionList.add(new SelectItem("hotelName1"));
selectionList.add(new SelectItem("hotelName2"));
selectionList.add(new SelectItem("hotelName3"));
selectionList.add(new SelectItem("hotelName4"));
passing the strings to be displayed directly to each selectItem (but
having no reference to the actual object hotel and its metadata) there
is no problem. Everything displays just fine an no converted is
requested. But then I don't have the meta information needed for
processing after the selection is made.
Any ideas?
Ciao,
Elenh