How to get both label and value from f:selectItems

前端 未结 5 1245
长发绾君心
长发绾君心 2020-11-30 06:05

I am working on a JSF page which has a dropdown based on List:


    <         


        
5条回答
  •  臣服心动
    2020-11-30 06:29

    What if the the value should be Integer and label String and both are needed in backing bean. Using Map in bean doesn't work because JSF interprets the map key as label. Ideally it would be a LinkedHashMap and search the text by a number.

    Seems upside down to search number (value) by a text (key). What if some implementation of JSF adds extra space to test or letter case changes for some reason. Then the value is not found from map.

提交回复
热议问题