selectManyCheckbox State Saving
--------------------------------
Key: MYFACES-3344
URL: https://issues.apache.org/jira/browse/MYFACES-3344
Project: MyFaces Core
Issue Type: Bug
Components: General
Affects Versions: 2.1.3
Environment: Primefaces 3.0.RC1-SNAPSHOT, WebSphere 8.0
Reporter: Keith Wong
Hi,
I have a problem when using p:selectManyCheckbox, as well as p:selectManyMenu,
with MyFaces 2. Here is the page fragment:
<p:inputTextarea value="#{customer.firstName}" required="true"/>
<p:selectManyCheckbox value="#{customer.phones}">
<f:selectItem itemValue="SS" itemLabel="Samsung"/>
<f:selectItem itemValue="LG" itemLabel="LG"/>
<f:selectItem itemValue="AP" itemLabel="Apple"/>
</p:selectManyCheckbox>
<p:commandButton value="Submit" process="@form" update="@form"/>
Steps to reproduce the problem:
1. Let the firstName field empty and click Submit
2. Type something in the firstName field and click Submit
Then, the following exception occurs, amendment to MyFaces is needed to capture
the stack trace,
[2011/10/4 12:29:01:093 CST] 0000001d UIComponentBa W 类
javax/faces/component/UIComponentBase 非法访问 "private" 类
java/util/Arrays$ArrayList
java.lang.IllegalAccessException: 类
javax/faces/component/UIComponentBase 非法访问 "private" 类
java/util/Arrays$ArrayList
at java.lang.J9VMInternals.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1345)
at
javax.faces.component.UIComponentBase.restoreAttachedState(UIComponentBase.java:1717)
at
javax.faces.component._DeltaStateHelper.restoreState(_DeltaStateHelper.java:614)
at
javax.faces.component.UIComponentBase.restoreState(UIComponentBase.java:1885)
at javax.faces.component.UIOutput.restoreState(UIOutput.java:213)
at javax.faces.component.UIInput.restoreState(UIInput.java:1012)
at
org.apache.myfaces.view.facelets.DefaultFaceletsStateManagementStrategy.restoreStateFromMap(DefaultFaceletsStateManagementStrategy.java:545)
at
org.apache.myfaces.view.facelets.DefaultFaceletsStateManagementStrategy.restoreStateFromMap(DefaultFaceletsStateManagementStrategy.java:581)
at
org.apache.myfaces.view.facelets.DefaultFaceletsStateManagementStrategy.restoreStateFromMap(DefaultFaceletsStateManagementStrategy.java:564)
at
org.apache.myfaces.view.facelets.DefaultFaceletsStateManagementStrategy.restoreStateFromMap(DefaultFaceletsStateManagementStrategy.java:564)
at
org.apache.myfaces.view.facelets.DefaultFaceletsStateManagementStrategy.restoreStateFromMap(DefaultFaceletsStateManagementStrategy.java:564)
at
org.apache.myfaces.view.facelets.DefaultFaceletsStateManagementStrategy.restoreStateFromMap(DefaultFaceletsStateManagementStrategy.java:564)
at
org.apache.myfaces.view.facelets.DefaultFaceletsStateManagementStrategy.restoreStateFromMap(DefaultFaceletsStateManagementStrategy.java:564)
at
org.apache.myfaces.view.facelets.DefaultFaceletsStateManagementStrategy.restoreView(DefaultFaceletsStateManagementStrategy.java:241)
at
org.apache.myfaces.application.StateManagerImpl.restoreView(StateManagerImpl.java:113)
at
org.apache.myfaces.shared.view.ViewDeclarationLanguageBase.restoreView(ViewDeclarationLanguageBase.java:106)
at
org.apache.myfaces.view.facelets.FaceletViewDeclarationLanguage.restoreView(FaceletViewDeclarationLanguage.java:1832)
at
org.apache.myfaces.application.ViewHandlerImpl.restoreView(ViewHandlerImpl.java:296)
at
org.apache.myfaces.lifecycle.RestoreViewExecutor.execute(RestoreViewExecutor.java:123)
at
org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:171)
at
org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:189)
at
com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1147)
at
com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:722)
at
com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:449)
at
com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:178)
at
com.ibm.ws.webcontainer.filter.WebAppFilterChain.invokeTarget(WebAppFilterChain.java:125)
at
com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:77)
at
com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:919)
at
com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1016)
at
com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:87)
at
com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:883)
at
com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1659)
at
com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:195)
at
com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:452)
at
com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:511)
at
com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:305)
at
com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:83)
at
com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
at
com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
at
com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204)
at
com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775)
at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1648)
After investigation, the cause could be in the saveAttachedState method of
UIComponentBase.java:
else if (attachedObject instanceof Collection)
{
if (ArrayList.class.equals(attachedObject.getClass()))
{
List<Object> lst = new ArrayList<Object>(((List<?>)
attachedObject).size());
The above fragment only consider if the attachedObject is an instance of
ArrayList. However, the object returned from PrimeFaces is created by
Arrays.asList, which is java.util.Arrays$ArrayList. So, when performing
restoreAttachedState, this private class could not be instantiated. So, I
suggest to change the line
if (ArrayList.class.equals(attachedObject.getClass()))
as this
if (ArrayList.class.equals(attachedObject.getClass()) ||
_ClassUtils.simpleClassForName("java.util.Arrays$ArrayList").equals(attachedObject.getClass()))
to solve the problem.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira