Getting the ItemLabel of selectOneMenu

Hi All,

I'm new to JSF and I'm trying to display the ItemLable of selectOneMenu in another page(page2) based upon the item selected by user in page1. I'm getting the ItemValue to be displayed in page2 but the actual requirement is to display the ItemLabel.

Thanks,

Prakash

[301 byte] By [kcpsunforuma] at [2007-11-26 15:47:25]
# 1
Then get the item label based on the item value.Good practice is to put all values and labels in a private map and use this as base to build the selectitems and check the selected items.
BalusCa at 2007-7-8 22:06:54 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

Thanks for the reply..

Code that I tried in a bean:

public void setSelectFrom(String selectFrom) {

this.selectFrom = selectFrom;

}

public List getSelectFrom() {

List selectedFrom = new ArrayList();

selectedFrom.add(new SelectItem("1","value1"));

selectedFrom.add(new SelectItem("2","value2"));

return selectedFrom;

}

Hope it will be same as selectOneMenu of JSF:

<af:selectOneChoice value="#{Model.selectFrom}">

<af:selectItem label="value1" value="1"/>

<af:selectItem label="value2" value="2"/>

</af:selectOneChoice>

kcpsunforuma at 2007-7-8 22:06:54 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3

I'm following the thread "jsf selectOneMenu problem"

Code in the Bean:

MyBean

private Car selectedCar; // + getter + setter- what will be the class "CAR"

public List getSelectCars() {

List selectCars = new ArrayList();

selectCars.add(new SelectItem(new Car("Alfa Romeo 156 GTA SW"), "Alfa Romeo 156 GTA SW"));

selectCars.add(new SelectItem(new Car("BMW E61 M5 Touring"), "BMW E61 M5 Touring"));

selectCars.add(new SelectItem(new Car("Maserati Quattroporte"), "Maserati Quattroporte"));

return selectCars;

}

kcpsunforuma at 2007-7-8 22:06:54 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...