How to bind List values to selectManyListbox in JSF

前端 未结 1 637
傲寒
傲寒 2020-12-10 22:22

The situation: I have a JavaServer Faces page and a session-scoped managed bean that has two ArrayList properties: one for holdi

相关标签:
1条回答
  • 2020-12-10 23:04

    The generic type information of List<Integer> is lost during runtime and therefore JSF/EL who sees only List is not able to identify that the generic type is Integer and assumes it to be default String (as that's the default type of the underlying HttpServletRequest#getParameter() call during apply request values phase).

    You need either to explicitly specify a Converter, you can use JSF builtin IntegerConverter:

    <h:selectManyListbox ... converter="javax.faces.Integer">
    

    or just to use Integer[] instead, whose type information is clearly known during runtime:

    private Integer[] selection;
    
    0 讨论(0)
提交回复
热议问题