com.sun.faces.renderkit.html_basic.MenuRenderer createCollection: Unable to create new Collection instance for type java.util.Arrays$ArrayList

后端 未结 1 1471
故里飘歌
故里飘歌 2021-01-02 10:53

I\'m trying to use JSF / SelectManyCheckBox tag with an enum :

Here is my xhtml code :

            
                &         


        
相关标签:
1条回答
  • 2021-01-02 11:38

    This will happen when the UISelectMany component's value being provided is created using Arrays#asList() method instead of new ArrayList().

    If a model value is already prepopulated, JSF will try to use exactly the same type to put submitted values in and set the new model value. However, the java.util.Arrays$ArrayList type as returned by Arrays#asList() is internal to java.util.Arrays class and not individually instantiable as in new Arrays$ArrayList(). Hence this exception.

    To fix this, make sure that the value is created using new ArrayList().

    Alternatively, explicitly specify the collection type via collectionType attribute as instructed in this closely related answer: org.hibernate.LazyInitializationException at com.sun.faces.renderkit.html_basic.MenuRenderer.convertSelectManyValuesForModel.

    <h:selectManyCheckbox ... collectionType="java.util.ArrayList">
    
    0 讨论(0)
提交回复
热议问题