JBoss Community

how to get values from selectOneMenu

created by yasser zairi in JBoss Tools - View the full discussion

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

Start a new discussion in JBoss Tools at Community