omid haghighatgoo
omid haghighatgoo

Reputation: 332

SelectItems with list of string in jsf

I have list of String like this in managed bean :

 List<String> roleList = Arrays.asList("MANAGER", "ADMIN", "USER");

I want to use it in a selectOneMenu like this :

        <f:selectItems itemLabel="#{userMB.roleList}" ....}"/>
  </h:selectOneMenu>

both value and lable Iwant to be the same

what I must do ?

Upvotes: 0

Views: 2212

Answers (2)

AmolRavan
AmolRavan

Reputation: 33

We can write a short code as below.

<f:selectItems value="#{userMB.roleList}"/>

Upvotes: 0

Mr.J4mes
Mr.J4mes

Reputation: 9266

<f:selectItems value="#{userMB.roleList}" var="role" 
               itemLabel="#{role}" itemValue="#{role}" />

Upvotes: 4

Related Questions