[
https://issues.apache.org/jira/browse/WICKET-349?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Kent Tong reopened WICKET-349:
------------------------------
This bug is still there in 1.2.6.
> ListView can't undo changes to model
> ------------------------------------
>
> Key: WICKET-349
> URL: https://issues.apache.org/jira/browse/WICKET-349
> Project: Wicket
> Issue Type: Bug
> Components: wicket
> Affects Versions: 1.2.5
> Environment: WinXP, Tomcat 5.5.
> Reporter: Kent Tong
> Fix For: trunk, 1.2.6
>
>
> Given the code below (adapted from the guestbook example):
> Form form = new Form("form") {
> protected void onSubmit() {
> List comments = listView.getList();
> listView.modelChanging();
> comments.add(new Comment(comment, new Date()));
> comment = "";
> listView.modelChanged();
> }
> };
> Perform the steps:
> 1) add "a" to the ListView and submit, bringing the page to version 1.
> 2) add "b" to the ListView and submit, bringing the page to version 2.
> 3) add "c" to the ListView and submit, bringing the page to version 3.
> 4) press Back twice.
> 5) add "x" to the ListView and submit. This will try to revert the page back
> to version 1. But it will fail with an IllegalStateException (full stack
> trace is shown below).
> This is because at step 3, the ListView contains two items: "a" and "b".
> Calling modelChanging() will store the model (a list containing "a" and "b")
> into a ModelChange object for later undo. The problem is, when this action is
> undone, ModelChange.undo() will call setModel() on the ListView, which will
> call removeAll() on itself. This will leave the ListView in a state different
> from the original (containing "a" and "b" items). This is not a problem if
> the ListView was to be rendered immediately (then it would create the items
> again). But in this case, the next step is to further undo the adding of item
> "b". However, the item's parent has just been set to null by removeAll().
> This causes Component.remove() to throw an exception.
> Full stack trace is here:
> Unexpected RuntimeException
> Root cause:
> java.lang.IllegalStateException: Cannot remove [MarkupContainer [Component id
> = 1, page = <No Page>, path = 1.ListItem]] from null parent!
> at wicket.Component.remove(Component.java:1469)
> at wicket.version.undo.Add.undo(Add.java:81)
> at wicket.version.undo.ChangeList.undo(ChangeList.java:93)
> at
> wicket.version.undo.UndoPageVersionManager.undo(UndoPageVersionManager.java:217)
> at
> wicket.version.undo.UndoPageVersionManager.getVersion(UndoPageVersionManager.java:167)
> at wicket.Page.getVersion(Page.java:589)
> at wicket.PageMap.get(PageMap.java:461)
> at wicket.Session.getPage(Session.java:447)
> at
> wicket.request.compound.DefaultRequestTargetResolverStrategy.resolveRenderedPage(DefaultRequestTargetResolverStrategy.java:215)
> at
> wicket.request.compound.DefaultRequestTargetResolverStrategy.resolve(DefaultRequestTargetResolverStrategy.java:153)
> at
> wicket.request.compound.AbstractCompoundRequestCycleProcessor.resolve(AbstractCompoundRequestCycleProcessor.java:48)
> at wicket.RequestCycle.step(RequestCycle.java:992)
> at wicket.RequestCycle.steps(RequestCycle.java:1084)
> at wicket.RequestCycle.request(RequestCycle.java:454)
> at wicket.protocol.http.WicketServlet.doGet(WicketServlet.java:219)
> at wicket.protocol.http.WicketServlet.doPost(WicketServlet.java:262)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
> at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
> at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
> at
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
> at
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
> at
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
> at
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
> at
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
> at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
> at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:825)
> at
> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:738)
> at
> org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:526)
> at
> org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
> at
> org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
> at java.lang.Thread.run(Thread.java:595)
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.