myfaces-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gabrielle Crawford (JIRA)" <...@myfaces.apache.org>
Subject [jira] Commented: (TRINIDAD-1674) Trinidad 2 - New NPE when adding component programatically
Date Thu, 07 Jan 2010 01:01:04 GMT

    [ https://issues.apache.org/jira/browse/TRINIDAD-1674?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12797422#action_12797422
] 

Gabrielle Crawford commented on TRINIDAD-1674:
----------------------------------------------

In ChildArrayList.add(int index, UIComponent element) you have this code:

    element.setParent(_parent);
    super.add(index, element);

What was happening is that calling setParent triggers an addEvent, but at the time StateManagementStrategyImpl.handleAddEvent
is called, the element hasn't actually been pushed into the child array, so the code in StateManagementStrategyImpl.handleAddEvent
gets an index of -1 for the newly added component, and assumes it's a facet, not an indexed
child, which it isn't. Changing the order of the calls so setParent is called after the element
is added to the child list solves the issue. It does not appear that the code called by super.add
relies on the parent having been set.

Fix is in ChildArrayList.add(int index, UIComponent element)

change the order of 

    element.setParent(_parent);
    super.add(index, element);

to 

    super.add(index, element);
    element.setParent(_parent);



> Trinidad 2 - New NPE when adding component programatically
> ----------------------------------------------------------
>
>                 Key: TRINIDAD-1674
>                 URL: https://issues.apache.org/jira/browse/TRINIDAD-1674
>             Project: MyFaces Trinidad
>          Issue Type: Bug
>    Affects Versions: 2.0.0-alpha
>            Reporter: Gabrielle Crawford
>         Attachments: web.xml.diff
>
>
> Wait for the fix for:
> TRINIDAD-1670 Trinidad 2 - NPE when adding component programatically
> 1. run partialAddComponent.jspx and follow the "set up for state saving test" link. 
> 2. modify web.xml  to test partial state saving
> 2. shut down and restart partialAddComponent.jspx
> 3. click the "add a component" button twice
> Get the following exception
> java.lang.NullPointerException
> at org.apache.myfaces.trinidad.component.FacetHashMap.put(FacetHashMap.java:55)
> at org.apache.myfaces.trinidad.component.FacetHashMap.put(FacetHashMap.java:31)
> at com.sun.faces.application.view.StateManagementStrategyImpl$4.invokeContextCallback(StateManagementStrategyImpl.java:293)
> at org.apache.myfaces.trinidad.component.UIXComponentBase.invokeOnComponent(UIXComponentBase.java:1548)
> at org.apache.myfaces.trinidad.component.UIXComponentBase.invokeOnChildrenComponents(UIXComponentBase.java:1469)
> at org.apache.myfaces.trinidad.component.UIXComponentBase.invokeOnComponent(UIXComponentBase.java:1562)
> at org.apache.myfaces.trinidad.component.UIXComponentBase.invokeOnChildrenComponents(UIXComponentBase.java:1469)
> at org.apache.myfaces.trinidad.component.UIXComponentBase.invokeOnComponent(UIXComponentBase.java:1562)
> at org.apache.myfaces.trinidad.component.UIXComponentBase.invokeOnChildrenComponents(UIXComponentBase.java:1469)
> at org.apache.myfaces.trinidad.component.UIXComponentBase.invokeOnComponent(UIXComponentBase.java:1562)
> at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:1262)
> at javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:681)
> at com.sun.faces.application.view.StateManagementStrategyImpl.restoreView(StateManagementStrategyImpl.java:284)
> at org.apache.myfaces.trinidadinternal.application.StateManagerImpl.restoreView(StateManagerImpl.java:523)
> at com.sun.faces.application.view.ViewHandlingStrategy.restoreView(ViewHandlingStrategy.java:131)
> at com.sun.faces.application.view.FaceletViewHandlingStrategy.restoreView(FaceletViewHandlingStrategy.java:430)
> at com.sun.faces.application.view.MultiViewHandler.restoreView(MultiViewHandler.java:143)
> at javax.faces.application.ViewHandlerWrapper.restoreView(ViewHandlerWrapper.java:288)
> at org.apache.myfaces.trinidadinternal.application.ViewHandlerImpl.restoreView(ViewHandlerImpl.java:293)
> at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:199)
> at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
> at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:110)
> at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
> at javax.faces.webapp.FacesServlet.service(FacesServlet.java:312)
> at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
> at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
> at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._doFilterImpl(TrinidadFilterImpl.java:247)
> at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(TrinidadFilterImpl.java:157)
> at org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(TrinidadFilter.java:92)
> at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
> at org.apache.myfaces.trinidaddemo.webapp.RedirectFilter.doFilter(RedirectFilter.java:97)
> at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
> at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
> at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
> at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
> at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
> at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
> at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:230)
> at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
> at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
> at org.mortbay.jetty.Server.handle(Server.java:326)
> at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:536)
> at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:930)
> at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:747)
> at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
> at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:405)
> at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
> at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582) 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message