JBoss Community

population a selectOneMenu Dynamically

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

Hi,

i want to populate a selectOneMenu Dynamically from my Bean, i used a map(id, value) but it populate my selectOneMenu with the ids not the values ,

here is the selectOneMenu:

_________________________________________________________________

<h:selectOneMenu id="select_cat">

         <f:selectItem itemLabel="--categorie"/>

         <f:selectItems value="#{valeursMBean.categories}"/>

</h:selectOneMenu>

__________________________________________________________________

here is the code of my Bean:

__________________________________________________________________

 

private transient ValeurRefService valeurefService;

private Map<String,Integer> categories = new HashMap<String,Integer>();

 

@PostConstruct

    public void init(){

       

         valeurefList = valeurefService.find();

        

         categories.clear();

 

         for (ValeurRef m : valeurefList) {

             categories.put(m.getIdValeurRef(),m.getCategorie());

         }

  

    }

Reply to this message by going to Community

Start a new discussion in JBoss Tools at Community