Sure; If i understand your problem the right way, you only need to
create the List of SelectItems this way:

selectItemList = new ArrayList<SelectItem>();

for (iterate over list of entities you want to transform to selectItems)
{
     SelectItem item = new SelectItem(string to display, id of entity);

     selectItemList .add(item);
}

The value of the selectOneMenu in the backend will then include the id
of the entity.

cheers,

Gerald

On 9/11/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
Hello everybody!

I am programming some JSF JSP pages with Eclipse JBoss and I get into
troubles. Here is my problem:

I need to display a list as follow:

M. Smith - Professor
Mrs Smith - Student
M. Martin - Student

For the moment, I am doing as follow:

I have a table of relations statut-person.
For each existing relation I get the name and the statut label (in the
application language).
I concatenate both (statut and name) in a String and store it in a list.
I display this list with a SelectOneMenu:
<h:selectOneMenu id="stpers" style="width:200px"
value="#{MyClass.relationFn}">
<f:selectItems value="#{MyClass.functionsPersToDisplay}" />
</h:selectOneMenu>

So when I get the selected item, I get again a String that I need to parse
to get back the function, the name and thus the relation.

Is there another way, easier, where I could get the relation id directly?
The selected item would returns an id but these id will not be displayed
And I would display the corresponding values for this id (statut and name of
the person). Using a hashtable maybe? but then is it possible with a
selectOneMenu?

Thanks for your help.
Best
Sophie




--
Gerald Müllan
Schelleingasse 2/11
1040 Vienna, Austria
0043 699 11772506
[EMAIL PROTECTED]

Reply via email to