I'm trying to use JSF / SelectManyCheckBox tag with an enum :
Here is my xhtml code :
<h:form id="searchForm">
<h:panelGrid columns="2">
<h:outputText value="Searched queues" />
<h:panelGroup>
<h:selectManyCheckbox layout="pageDirection" value="#{jmsErrorController.errorSearchCriteria.searchedQueues}" converter="queueConverter">
<f:selectItems value="#{jmsErrorController.completeQueueList}" />
</h:selectManyCheckbox>
</h:panelGroup>
</h:panelGrid>
<h:commandButton action="#{jmsErrorController.search}"
value="Search !" />
</h:form>
I've add a converter as stated in an other post.
It seems to work fine but I see this stack trace on the console :
28-Jun-2013 09:07:46 com.sun.faces.renderkit.html_basic.MenuRenderer createCollection
SEVERE: Unable to create new Collection instance for type java.util.Arrays$ArrayList
java.lang.InstantiationException: java.util.Arrays$ArrayList
at java.lang.Class.newInstance0(Class.java:340)
at java.lang.Class.newInstance(Class.java:308)
at com.sun.faces.renderkit.html_basic.MenuRenderer.createCollection(MenuRenderer.java:907)
at com.sun.faces.renderkit.html_basic.MenuRenderer.convertSelectManyValuesForModel(MenuRenderer.java:367)
at com.sun.faces.renderkit.html_basic.MenuRenderer.convertSelectManyValue(MenuRenderer.java:129)
at com.sun.faces.renderkit.html_basic.MenuRenderer.getConvertedValue(MenuRenderer.java:315)
at javax.faces.component.UIInput.getConvertedValue(UIInput.java:1030)
at javax.faces.component.UIInput.validate(UIInput.java:960)
at javax.faces.component.UIInput.executeValidate(UIInput.java:1233)
at javax.faces.component.UIInput.processValidators(UIInput.java:698)
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1214)
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1214)
at javax.faces.component.UIForm.processValidators(UIForm.java:253)
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1214)
at javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:1172)
at com.sun.faces.lifecycle.ProcessValidationsPhase.execute(ProcessValidationsPhase.java:76)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300)
at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.doIt(WebAppServletContext.java:3684)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3650)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2268)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2174)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1446)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
After this stacktrace, the application seems to work fine but I wonder why is there such a stacktrace..
Can someone help me?
Thanks.
Stéphane.
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">
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With