yasser zairi [
http://community.jboss.org/people/yasser_z] created the discussion
"how to get values from selectOneMenu"
To view the discussion, visit:
http://community.jboss.org/message/617588#617588
--------------------------------------------------------------
Hi every one, this thread may be irrelevent to this forum but since i'm using jboss i
prefere to post it here.
the issu is that i'm populate a selectOneMenu dynamically using a map, and i want to
get the value selected by the User, but i get only its key.
here is the selectOneMenu code :
___________________________________
<h:selectOneMenu id="select_cat"
value="#{valeursMBean.selectedItem1}" >
<f:selectItem itemLabel="--categorie"/>
<f:selectItems value="#{valeursMBean.categories}"/>
</h:selectOneMenu>
___________________________________
here is the bean code related to it :
...
private String selectedItem1;
@PostConstruct
public void init(){
valeurefList = valeurefService.find();
categories.clear();
codeisins.clear();
denominations.clear();
etats.clear();
datesecheance.clear();
for (ValeurRef m : valeurefList) {
categories.put(m.getCategorie(),m.getIdValeurRef());
}
for (ValeurRef m : valeurefList) {
codeisins.put(m.getCodeIsin(),m.getIdValeurRef());
}
for (ValeurRef m : valeurefList) {
denominations.put(m.getDenomination(),m.getIdValeurRef());
}
for (ValeurRef m : valeurefList) {
etats.put(m.getEtat(),m.getIdValeurRef());
}
for (ValeurRef m : valeurefList) {
datesecheance.put(m.getDateEcheance().toString(),m.getIdValeurRef());
}
}
public void takeSelection(){
System.out.println("value of "+selectedItem1+" is
"+categories.get(selectedItem1));
}
...
and it prints ( value of 3 is null ) when i select an element in my selectOneMenu.
can anyone tell me what is the best way to do that ?
Regards .
--------------------------------------------------------------
Reply to this message by going to Community
[
http://community.jboss.org/message/617588#617588]
Start a new discussion in JBoss Tools at Community
[
http://community.jboss.org/choose-container!input.jspa?contentType=1&...]