Yes you are right; I do not need to separate each String as I get the id directly. Sorry, Thanks for your help Sophie
-----Message d'origine----- De : Gerald Müllan [mailto:[EMAIL PROTECTED] Envoyé : lundi 11 septembre 2006 13:39 À : MyFaces Discussion; [EMAIL PROTECTED] Objet : Re: SelectOneMenu relationFn will hold the value of the id. So if the entity has the id 23, relationFn results in 23. Sorry, i have permuted the arguments; id comes first then the label (description). You can also concatenate the outputted String (string to display + " " + string to display), i don´t see a need for two arguments of display strings here. cheers, Gerald On 9/11/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Thanks a lot. So that means that the returned selected item will be the id > of entity in this case? In my example MyClass.relationFn will have the type > of the id of entity? > > And if I want to display more than one string is it possible to do something > like this: > > SelectItem item = new SelectItem (string to display, string to display, id > of entity) > > ? > > Thanks again > Sophie > > -----Message d'origine----- > De: Gerald Müllan [mailto:[EMAIL PROTECTED] > Envoyé: lundi 11 septembre 2006 12:25 > Ŕ: MyFaces Discussion; [EMAIL PROTECTED] > Objet: Re: SelectOneMenu > > 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] > > -- Gerald Müllan Schelleingasse 2/11 1040 Vienna, Austria 0043 699 11772506 [EMAIL PROTECTED]

