我想使用inlinframe来显示弹出预览打印页面,这是我的问题:
爪哇:
Form form = new Form("form");
form.setOutputMarkupId(true);
form.add(new AjaxSubmitLink("test") {
@Override
protected void onSubmit(AjaxRequestTarget art, Form<?> form) {
containerPrint.add(/*another inlineframe*/)
art.addComponent(containerPrint);
}
});
add(form);
HTML:
<form wicket:id="form">
<input type="button" wicket:id="test"></input>
</form>
<div wicket:id="page" style="width: 0px;height: 0px">
<iframe wicket:id="printPage" width="0px" height="0px">
</iframe>
</div>
我想通过点击测试按钮将inlineiframe替换为另一个inlineiframe 但是点击按钮即可获得此问题
WicketMessage: org.apache.wicket.WicketRuntimeException: component form:panel:panel:panel:mcGridViewInfo:GridViewInfo:form:<b>test not found on page</b> ir.mersad.ui.authenticationAndAuthorization.Office[id = 1], listener interface = [RequestListenerInterface name=IActivePageBehaviorListener, method=public abstract void org.apache.wicket.behavior.IBehaviorListener.onRequest()]
Root cause:
org.apache.wicket.WicketRuntimeException: component form:panel:panel:panel:mcGridViewInfo:GridViewInfo:form:test not found on page ir.mersad.ui.authenticationAndAuthorization.Office[id = 1], listener interface = [RequestListenerInterface name=IActivePageBehaviorListener, method=public abstract void org.apache.wicket.behavior.IBehaviorListener.onRequest()]
at org.apache.wicket.request.AbstractRequestCycleProcessor.resolveListenerInterfaceTarget(AbstractRequestCycleProcessor.java:427)
at org.apache.wicket.request.AbstractRequestCycleProcessor.resolveRenderedPage(AbstractRequestCycleProcessor.java:472)
at org.apache.wicket.protocol.http.WebRequestCycleProcessor.resolve(WebRequestCycleProcessor.java:144)
at org.apache.wicket.RequestCycle.step(RequestCycle.java:1339)
at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1465)
at org.apache.wicket.RequestCycle.request(RequestCycle.java:545)
at org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:486)
at org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:319)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:999)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:565)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:309)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
Complete stack:
org.apache.wicket.protocol.http.request.InvalidUrlException: org.apache.wicket.WicketRuntimeException: component form:panel:panel:panel:mcGridViewInfo:GridViewInfo:form:test not found on page ir.mersad.ui.authenticationAndAuthorization.Office[id = 1], listener interface = [RequestListenerInterface name=IActivePageBehaviorListener, method=public abstract void org.apache.wicket.behavior.IBehaviorListener.onRequest()]
at org.apache.wicket.protocol.http.WebRequestCycleProcessor.resolve(WebRequestCycleProcessor.java:262)
at org.apache.wicket.RequestCycle.step(RequestCycle.java:1339)
at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1465)
at org.apache.wicket.RequestCycle.request(RequestCycle.java:545)
at org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:486)
我已经知道问题在于:
container.add(new InlineFrame("printPage", new EmptyPage()));
当我用标签替换它时它的工作正常,但我不知道这是什么问题
答案 0 :(得分:2)
问题是什么并不完全清楚(有些代码显然缺失了)。看起来您正在添加新组件,而不是替换旧组件。
试试这样:
public class HomePage extends WebPage {
private InlineFrame iframe = new InlineFrame("iframe", new OtherPage());
public HomePage() {
iframe.setOutputMarkupId(true);
Form form = new Form("form");
form.setOutputMarkupId(true);
form.add(new AjaxSubmitLink("test") {
@Override
protected void onSubmit(AjaxRequestTarget art, Form<?> form) {
InlineFrame newIframe = new InlineFrame("iframe", new OtherPage());
iframe.replaceWith(newIframe);
iframe = newIframe;
art.add(iframe);
}
});
add(form, iframe);
}
}
非常重要
replaceWith
以便Wicket可以相应地更新组件树答案 1 :(得分:0)
只需替换上一帧
@Override
public void onClick(AjaxRequestTarget target) {
InlineFrame newIframe = new InlineFrame("iframe", PersonalInformationPage.class);
iframe.replaceWith(newIframe);
iframe = newIframe;
target.add(iframe);
}