Search code examples
jsf-2

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 ?


Solution

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