How to access Map key in jsf datatable

前端 未结 4 1689
天命终不由人
天命终不由人 2020-12-21 07:30

I\'m getting the error javax.el.PropertyNotFoundException: /member/apps/cms/edit.xhtml @228,49 value=\"#{props.key}\": Property \'key\' not found on type java.util.Has

4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-21 07:49

    The dataTable must receive a Collection (for example, a List). Map doesn't implement the Collection interface. You should convert your map into a list and modify it, then convert the list back into your map. Here's a good link showing how to do it:

    • Display HashMap Content in JSF Page

    Of course, I won't recommend you to add logic in the getter/setter, instead use 2 different attributes and keep the getter and setter the cleanest possible way.

提交回复
热议问题