检票口嵌套 ListView(3 次)

Posted

技术标签:

【中文标题】检票口嵌套 ListView(3 次)【英文标题】:wicket nested ListView (3 times) 【发布时间】:2016-03-12 04:36:05 【问题描述】:

我正在尝试使用 apache wicket (6) 呈现一个简单的可折叠列表,如下所示:

- A
    - a
        - 0
        - 1
    - b
        - 2
        - ...
- B
    - c
        - ...
    - d
        - ...

目前只有字符串可以渲染。折叠是用 javascript 完成的。 html 代码结构为带有 div 标签的 ul 列表:

<ul>
    <li wicket:id="listOne">
        <div wicket:id="labelOne"></div>

        <li wicket:id="listTwo">
            <div wicket:id="labelTwo"></div>

            <li wicket:id="listThree">
                // actual elements
            </li>
        </li>
    </li>
</ul>

最终输出应该包含一个标题,然后是所有子元素。 Java 代码如下所示(每一层一个方法):

private ListView<String> listItemsLayer0()
    List<String> list = Arrays.asList("A", "B");

    return new ListView<String>("layer1List", list)
        private static final long serialVersionUID = 5656024677354451474L;

        @Override
        protected void populateItem(ListItem<String> item) 
            item.add(new Label("layer0Label", item.getModelObject()));
            item.add(listItemsLayer1());
        
    ;

第一个列表是使用拦截器添加的。 所以它最多可以工作两层。但如果我添加第三个,我会得到以下 execption:

没想到一个新的 ContainerElement 而另一个正在等待它的元素访问!

我该如何解决这个问题?为什么不能嵌套在两层之上?

完整的堆栈跟踪:

java.lang.IllegalStateException: Did not expect a new ContainerElement while another is waiting for its element visit!
 at org.nocket.gen.page.visitor.bind.BindingVisitor.visitContainerOpen(BindingVisitor.java:293)
 at org.nocket.gen.page.element.ContainerElement.accept(ContainerElement.java:22)
 at org.nocket.gen.page.visitor.GeneratedBindingVisitor.visitContainerOpen(GeneratedBindingVisitor.java:181)
 at org.nocket.gen.page.element.ContainerElement.accept(ContainerElement.java:22)
 at org.nocket.gen.page.PageProcessor.traverse(PageProcessor.java:104)
 at org.nocket.gen.page.PageProcessor.traverse(PageProcessor.java:115)
 at org.nocket.gen.page.PageProcessor.traverse(PageProcessor.java:115)
 at org.nocket.gen.page.PageProcessor.traverse(PageProcessor.java:115)
 at org.nocket.gen.page.PageProcessor.traverse(PageProcessor.java:115)
 at org.nocket.gen.page.PageProcessor.traverse(PageProcessor.java:115)
 at org.nocket.gen.page.PageProcessor.traverse(PageProcessor.java:115)
 at org.nocket.gen.page.PageProcessor.traverse(PageProcessor.java:115)
 at org.nocket.gen.page.PageProcessor.process(PageProcessor.java:61)
 at org.nocket.gen.page.GeneratedBinding.bind(GeneratedBinding.java:135)
 at de.arvato.crmit.nocket.spring.extension.AbstractNocketSpringPage.bindGeneratedBindings(AbstractNocketSpringPage.java:71)
 at de.arvato.crmit.nocket.spring.extension.AbstractNocketSpringPage.<init>(AbstractNocketSpringPage.java:44)
 at de.arvato.crmit.rio.pages.base.BasePage.<init>(BasePage.java:51)
 at de.arvato.crmit.rio.pages.dokumentencenter.DokumentencenterViewPage.<init>(DokumentencenterViewPage.java:44)
 at java.lang.reflect.Constructor.newInstance(Unknown Source)
 at org.apache.wicket.session.DefaultPageFactory.newPage(DefaultPageFactory.java:175)
 at org.apache.wicket.session.DefaultPageFactory.newPage(DefaultPageFactory.java:67)
 at org.apache.wicket.DefaultMapperContext.newPageInstance(DefaultMapperContext.java:133)
 at org.apache.wicket.core.request.handler.PageProvider.resolvePageInstance(PageProvider.java:268)
 at org.apache.wicket.core.request.handler.PageProvider.getPageInstance(PageProvider.java:166)
 at org.apache.wicket.request.handler.render.PageRenderer.getPage(PageRenderer.java:78)
 at org.apache.wicket.request.handler.render.WebPageRenderer.respond(WebPageRenderer.java:266)
 at org.apache.wicket.core.request.handler.RenderPageRequestHandler.respond(RenderPageRequestHandler.java:165)
 at org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respond(RequestCycle.java:861)
 at org.apache.wicket.request.RequestHandlerStack.execute(RequestHandlerStack.java:64)
 at org.apache.wicket.request.cycle.RequestCycle.execute(RequestCycle.java:261)
 at org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.java:218)
 at org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:289)
 at org.apache.wicket.protocol.http.WicketFilter.processRequestCycle(WicketFilter.java:259)
 at org.apache.wicket.protocol.http.WicketFilter.processRequest(WicketFilter.java:201)
 at org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:282)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
 at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:316)
 at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:126)
 at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:90)
 at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
 at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:114)
 at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
 at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:122)
 at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
 at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111)
 at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
 at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:169)
 at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
 at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:48)
 at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
 at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:120)
 at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
 at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:64)
 at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
 at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
 at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:91)
 at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
 at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:53)
 at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
 at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
 at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:213)
 at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:176)
 at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:344)
 at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:261)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
 at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
 at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518)
 at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1096)
 at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:674)
 at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1500)
 at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1456)
 at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
 at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
 at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
 at java.lang.Thread.run(Unknown Source)

Complete stack:

org.apache.wicket.WicketRuntimeException: Can't instantiate page using constructor 'public de.arvato.crmit.rio.pages.dokumentencenter.DokumentencenterViewPage()'. An exception has been thrown during construction!
 at org.apache.wicket.session.DefaultPageFactory.newPage(DefaultPageFactory.java:194)
 at org.apache.wicket.session.DefaultPageFactory.newPage(DefaultPageFactory.java:67)
 at org.apache.wicket.DefaultMapperContext.newPageInstance(DefaultMapperContext.java:133)
 at org.apache.wicket.core.request.handler.PageProvider.resolvePageInstance(PageProvider.java:268)
 at org.apache.wicket.core.request.handler.PageProvider.getPageInstance(PageProvider.java:166)
 at org.apache.wicket.request.handler.render.PageRenderer.getPage(PageRenderer.java:78)
 at org.apache.wicket.request.handler.render.WebPageRenderer.respond(WebPageRenderer.java:266)
 at org.apache.wicket.core.request.handler.RenderPageRequestHandler.respond(RenderPageRequestHandler.java:165)
 at org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respond(RequestCycle.java:861)
 at org.apache.wicket.request.RequestHandlerStack.execute(RequestHandlerStack.java:64)
 at org.apache.wicket.request.cycle.RequestCycle.execute(RequestCycle.java:261)
 at org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.java:218)
 at org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:289)
 at org.apache.wicket.protocol.http.WicketFilter.processRequestCycle(WicketFilter.java:259)

 java.lang.reflect.InvocationTargetException
 at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
 at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
 at java.lang.reflect.Constructor.newInstance(Unknown Source)
 at org.apache.wicket.session.DefaultPageFactory.newPage(DefaultPageFactory.java:175)
 at org.apache.wicket.session.DefaultPageFactory.newPage(DefaultPageFactory.java:67)
 at org.apache.wicket.DefaultMapperContext.newPageInstance(DefaultMapperContext.java:133)
 at org.apache.wicket.core.request.handler.PageProvider.resolvePageInstance(PageProvider.java:268)
 at org.apache.wicket.core.request.handler.PageProvider.getPageInstance(PageProvider.java:166)
 at org.apache.wicket.request.handler.render.PageRenderer.getPage(PageRenderer.java:78)
 at org.apache.wicket.request.handler.render.WebPageRenderer.respond(WebPageRenderer.java:266)
 at org.apache.wicket.core.request.handler.RenderPageRequestHandler.respond(RenderPageRequestHandler.java:165)
 at org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respond(RequestCycle.java:861)
 at org.apache.wicket.request.RequestHandlerStack.execute(RequestHandlerStack.java:64)
 at org.apache.wicket.request.cycle.RequestCycle.execute(RequestCycle.java:261)
 at org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.java:218)
 at org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:289)
 at org.apache.wicket.protocol.http.WicketFilter.processRequestCycle(WicketFilter.java:259)

gengui.util.SevereGUIException: On element: <li wicket:id="row"> <span wicket:id="label">the label</span> </li>
 at org.nocket.gen.page.PageProcessor.traverse(PageProcessor.java:111)
 at org.nocket.gen.page.PageProcessor.traverse(PageProcessor.java:115)
 at org.nocket.gen.page.PageProcessor.traverse(PageProcessor.java:115)
 at org.nocket.gen.page.PageProcessor.traverse(PageProcessor.java:115)
 at org.nocket.gen.page.PageProcessor.traverse(PageProcessor.java:115)
 at org.nocket.gen.page.PageProcessor.traverse(PageProcessor.java:115)
 at org.nocket.gen.page.PageProcessor.traverse(PageProcessor.java:115)
 at org.nocket.gen.page.PageProcessor.traverse(PageProcessor.java:115)
 at org.nocket.gen.page.PageProcessor.process(PageProcessor.java:61)
 at org.nocket.gen.page.GeneratedBinding.bind(GeneratedBinding.java:135)
 at de.arvato.crmit.nocket.spring.extension.AbstractNocketSpringPage.bindGeneratedBindings(AbstractNocketSpringPage.java:71)
 at de.arvato.crmit.nocket.spring.extension.AbstractNocketSpringPage.<init>(AbstractNocketSpringPage.java:44)
 at de.arvato.crmit.rio.pages.base.BasePage.<init>(BasePage.java:51)
 at de.arvato.crmit.rio.pages.dokumentencenter.DokumentencenterViewPage.<init>(DokumentencenterViewPage.java:44)
 at java.lang.reflect.Constructor.newInstance(Unknown Source)
 at org.apache.wicket.session.DefaultPageFactory.newPage(DefaultPageFactory.java:175)
 at org.apache.wicket.session.DefaultPageFactory.newPage(DefaultPageFactory.java:67)
 at org.apache.wicket.DefaultMapperContext.newPageInstance(DefaultMapperContext.java:133)
 at org.apache.wicket.core.request.handler.PageProvider.resolvePageInstance(PageProvider.java:268)
 at org.apache.wicket.core.request.handler.PageProvider.getPageInstance(PageProvider.java:166)
 at org.apache.wicket.request.handler.render.PageRenderer.getPage(PageRenderer.java:78)
 at org.apache.wicket.request.handler.render.WebPageRenderer.respond(WebPageRenderer.java:266)
 at org.apache.wicket.core.request.handler.RenderPageRequestHandler.respond(RenderPageRequestHandler.java:165)
 at org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respond(RequestCycle.java:861)
 at org.apache.wicket.request.RequestHandlerStack.execute(RequestHandlerStack.java:64)
 at org.apache.wicket.request.cycle.RequestCycle.execute(RequestCycle.java:261)
 at org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.java:218)
 at org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:289)
 at org.apache.wicket.protocol.http.WicketFilter.processRequestCycle(WicketFilter.java:259)

【问题讨论】:

你能发布完整的堆栈跟踪 我忘了说:我也使用 nocket(见 GitHub),但这里没有使用。已将完整堆栈跟踪添加到帖子。 好吧,至少我通过为面板创建一个单独的 HTML 文件来修复示例。 【参考方案1】:

这是 Nocket 库中的一个错误。我的德语不太好,所以我无法理解它的目的。

Apache Isis 还为 Naked Objects 提供 Wicket 查看器。

【讨论】:

你怎么知道它是 nocket 中的错误?那你能在 GitHub 上创建一个问题吗?我现在开发 nocket 的人,它可能会帮助他们:) stacktrace 的最后几行表明这是 Nocket 的问题。如果你证明我错了,我会很高兴。

以上是关于检票口嵌套 ListView(3 次)的主要内容,如果未能解决你的问题,请参考以下文章

颤振键盘隐藏嵌套列表视图中的文本字段

AndroidUI系列--在DecorView层解决RecyclerView和ScrollView的滑动冲突

listview.setSelection()

ScrollView与ListView嵌套使用,导致ListView下拉失效

C# winform ListView+CheckBox的做法

ListView添加节点