2015-01-17 36 views
1

嗨,我想在兩個面板之間導航。我的代碼有一個條件,如果爲false,則必須返回實際面板,參數依次在feedbackpanel中打印錯誤消息。替換面板使用替換在門票

條件爲真時,出現此錯誤。

SearchInnerPanel.java:

(TabPanel1.this.getParent()).getParent().replaceWith(new JobDetails("innerpanel", params)); 

JobDetails.java:

list = DBUtils.retrieve(params.get("jobnum").toString()); 

      if (list.size() == 0) { 
       PageParameters params1 = new PageParameters(); 
       params1.add("jobnum", jnum); 

       AgileJobDetails.this.replaceWith(new SearchInnerPanel("innerpanel", params1)); 
      } 

錯誤日誌:

org.apache.wicket.WicketRuntimeException: Method onFormSubmitted of interface org.apache.wicket.markup.html.form.IFormSubmitListener targeted at [Form [Component id = jobnumform]] on component [Form [Component id = jobnumform]] threw an exception 
    at org.apache.wicket.RequestListenerInterface.internalInvoke(RequestListenerInterface.java:268) 
    at org.apache.wicket.RequestListenerInterface.invoke(RequestListenerInterface.java:216) 
    at org.apache.wicket.core.request.handler.ListenerInterfaceRequestHandler.invokeListener(ListenerInterfaceRequestHandler.java:243) 
    at org.apache.wicket.core.request.handler.ListenerInterfaceRequestHandler.respond(ListenerInterfaceRequestHandler.java:236) 
    at org.apache.wicket.core.request.handler.RequestSettingRequestHandler.respond(RequestSettingRequestHandler.java:78) 
    at org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respond(RequestCycle.java:862) 
    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:241) 
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) 
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220) 
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122) 
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:610) 
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170) 
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98) 
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950) 
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116) 
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408) 
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1040) 
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607) 
    at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2441) 
    at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2430) 
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) 
    at java.lang.Thread.run(Thread.java:745) 
Caused by: java.lang.reflect.InvocationTargetException 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
    at java.lang.reflect.Method.invoke(Method.java:606) 
    at org.apache.wicket.RequestListenerInterface.internalInvoke(RequestListenerInterface.java:258) 
    ... 29 more 
Caused by: java.lang.IllegalStateException: This method can only be called on a component that has already been added to its parent. 
    at org.apache.wicket.Component.replaceWith(Component.java:2754) 
    at com.CCC.aaa.des.JobDetails.<init>(JobDetails.java:40) 
    at com.CCC.aaa.des.SearchInnerPanel$TabPanel1$1.onSubmit(SearchInnerPanel.java:130) 
    at org.apache.wicket.markup.html.form.Form.delegateSubmit(Form.java:1266) 
    at org.apache.wicket.markup.html.form.Form.process(Form.java:938) 
    at org.apache.wicket.markup.html.form.Form.onFormSubmitted(Form.java:770) 
    at org.apache.wicket.markup.html.form.Form.onFormSubmitted(Form.java:703) 
    ... 34 more 

請建議如何重定向到實際面板。 謝謝

回答

2

將JobDetails的代碼片段從構造函數移到#onInitialize()方法。在那裏它已經被添加到它的父項,並且可以替換它。