2017-04-26 44 views
0

我将应用程序从较旧版本的wicket迁移到wicket 8.某些页面正常工作(简单页面如登录)。这些页面不使用扩展机制。 当我访问具有该机制的页面时,它不起作用。我不知道这是否是一个错误,但我尝试了一切,找不到解决方案。 我正在使用检票8.0.0-M5(我知道这不是一个稳定版本)。任何人都有同样的问题? 这里是我的代码:Wicket 8 - 扩展机制不起作用

WerklijstPageXXX.html

<html xmlns:wicket> 
<body> 
    <wicket:extend> 
     <div wicket:id="panelXXX"></div> 
    </wicket:extend> 
</body> 

WerklijstPanelXXX.html

<wicket:head xmlns:wicket> 
</wicket:head> 

<wicket:panel xmlns:wicket> 
    <div wicket:id="filter"> 
     <div wicket:id="label"></div> 
    </div> 
</wicket:panel> 

WerklijstPageXXX.java

public class WerklijstPageXXX extends BasePage { 

private WerklijstPanelXXX werklijstPanel; 

public WerklijstPageXXX() { 
    werklijstPanel = new WerklijstPanelXXX("panelXXX"){}; 
    add(werklijstPanel); 
} 

@Override 
public Panel getContextPanel(String id) 
{ 
    return werklijstPanel.getWerklijstFilterPanel(); 
} 

WerklijstPanelXXX.java

public abstract class WerklijstPanelXXX extends Panel { 
private static final Logger LOG = LoggerFactory 
     .getLogger(WerklijstPanelXXX.class); 

private Panel filterPanel; 

public WerklijstPanelXXX(String id) { 
    super(id); 
    WebMarkupContainer upperPanel = new WebMarkupContainer("filter"); 
    filterPanel = new Panel("filterPanel") { 

    }; 

    add(upperPanel); 

    upperPanel.add(new Label("label")); 


} 

public Panel getWerklijstFilterPanel() { 
    return filterPanel; 
} 

编辑: BasePage.html(它的一部分)

<div id="body" class="body"> 
       <div id="aside" class="aside"> 
        <div wicket:id="contextPanel"></div> 
       </div> 
       <div id="content" class="content"> 
        <div class="padding"> 
         <wicket:child></wicket:child> 
        </div> 
       </div> 
      </div> 

BasePage.java

@Override 
protected void onInitialize() { 
    super.onInitialize(); 
    add(getContextPanel("contextPanel")); 
    addTabMenu(); 
    addMenu(); 
    addPatientBar(); 
} 

错误:

根源:

org.apache.wicket.WicketRuntimeException:下面的组件无法呈现。可能的原因可能是这样的: 1)你已经在代码中添加了一个组件,但忘记在标记中引用它(因此组件将不会被渲染), 2)如果你的组件被添加到父容器中,子容器的标记包含它们。

  1. [WerklijstPanelXXX [组件ID = panelXXX,页= nl.philips.raris.web.werklijst.WerklijstPageXXX,路径= panelXXX,类型= nl.philips.raris.web.werklijst.WerklijstPanelXXX,ISVISIBLE =真, [WebMarkupContainer [Component ID = filter]]]
  2. [WebMarkupContainer [Component id = filter,page = nl.philips.raris.web.werklijst.WerklijstPageXXX,path = panelXXX:filter,type = org.apache.wicket.markup.html.WebMarkupContainer,isVisible = true,isVersioned = true],children = [Component id = label]]
  3. [Component id = label,page = nl.philips.raris.web.werklijst .WerklijstPageXXX,path = panelXXX:filter:label,type = org.a pache.wicket.markup.html.basic.Label,isVisible = true,isVersioned = true]
  4. [Panel [Component id = filterPanel,page = nl.philips.raris.web.werklijst.WerklijstPageXXX,path = filterPanel,键入= org.apache.wicket.markup.html.panel.Panel,ISVISIBLE =真,isVersioned = TRUE]]

    在org.apache.wicket.Page.checkRendering(Page.java:662) 在有机apache.wicket.Page.onAfterRender(Page.java:805) at org.apache.wicket.markup.html.WebPage.onAfterRender(WebPage.java:209) at org.apache.wicket.Component.afterRender(Component。 java:919) at org。apache.wicket.Component.render(Component.java:2335) at org.apache.wicket.Page.renderPage(Page.java:987) at org.apache.wicket.request.handler.render.WebPageRenderer.renderPage( (WebPageRenderer.java:124) at org.apache.wicket.core.request.handler.RenderPageRequestHandler.respond(RenderPageRequestHandler。org.apache.wicket.request.handler.render.WebPageRenderer.respond(WebPageRenderer.java:236) 。 Java的:175) 在org.apache.wicket.request.cycle.RequestCycle $ HandlerExecutor.respond(RequestCycle.java:912) 在org.apache.wicket.request.RequestHandlerExecutor.execute(RequestHandlerExecutor.java:65) 在org.apache.wicket.request.cycle.RequestCycle.execute(RequestCycle.java:283) at org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCyc le.java:253) 在org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:221) 在org.apache.wicket.protocol.http.WicketFilter.processRequestCycle(WicketFilter.java:262) at org.apache.wicket.protocol.http.WicketFilter.processRequest(WicketFilter.java:204) at org.apache.wicket.protocol.http.WicketServlet.doGet(WicketServlet.java:137) at javax.servlet。 httphttpServlet.service(HttpServlet.java:687) at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:808) at org.eclipse.jetty.servlet.ServletHandler $ CachedChain.doFilter(ServletHandler.java:1669) at org.apache.shiro.web.servlet.AbstractShiroFilter.exe cuteChain(AbstractShiroFilter.java:449) at org.apache.shiro.web.servlet.AbstractShiroFilter $ 1.call(AbstractShiroFilter.java:365) at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java :90) at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83) at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:387) at org .apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362) at org.springframework.web.filter org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125) .DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346) at org.springframework.web.filter.DelegatingFilterProxy.doFilter (DelegatingFilterProxy.java:262) at org.eclipse.jetty.servlet.ServletHandler $ CachedChain.doFilter(ServletHandler.java:1652) at org.springframework.orm.hibernate4.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:151 ) 在org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) 在org.eclipse.jetty.servlet.ServletHandler $ CachedChain.doFilter(ServletHandler.java:1652)

+0

你是什么意思的“不行”?它只是显示基本页面还是会出现异常?如果你分享了BasePage的代码+ html,它可能会很好。如果BasePage中没有正确的标记,标记将不起作用。 –

+0

对不起。我忘了添加错误和BasePage的东西。 – fselvatici

回答

2

Java和HTML组件树应该匹配。

您的HTML状态:<div wicket:id="*contextPanel*"></div>,但您的Java代码将返回一个ID为filterPanel的面板。

public WerklijstPageXXX() { 
    werklijstPanel = new WerklijstPanelXXX("panelXXX"){}; 
    add(werklijstPanel); 
} 

@Override 
public Panel getContextPanel(String id) // HERE id is ignored 
{ 
    return werklijstPanel.getWerklijstFilterPanel(); // This returns a panel with id `filterPanel` 
} 
+0

contextPanel与BasePage中的div对应 – fselvatici

+0

我已经扩展了我的答案。 –