好的,这就去。这是我的第一个 wicket 应用程序,我正在尝试使用 pushpanel 示例集成 icepush。
我想要做的是通过从另一个类调用“updatePanel(String content)”方法将更新推送到面板。
这是代码。
在我扩展的 PushPanel 中,我有:
public AsyncCommsPanel(String id) {
super(id);
this.setOutputMarkupId(true);
ajaxForm = new Form("ajaxForm");
ajaxForm.setOutputMarkupId(true);
ajaxForm.add(textStore = new Label("textStore",""));
ajaxForm.add(new AjaxButton("updateButton") {
@Override
protected void onSubmit(AjaxRequestTarget target, Form form) {
System.out.println("Update button pressed!");
/* CODE TO PULL NEW DATA FROM ELSEWHERE */
/* UPDATE TAKES TIME SO HAS ITS OWN CALLBACK */
}
@Override
protected void onError(AjaxRequestTarget target, Form<?> form) {
System.out.println("Update button error.");
}
});
add(ajaxForm);
}
@Override
protected void pushCallback(AjaxRequestTarget target) {
target.add(ajaxForm);
}
public void updatePanel(String updateString) {
/* THIS METHOD SHOULD ALLOW THE PANEL TO BE UPDATED FROM ELSEWHERE */
if (textStore != null) ajaxForm.remove(textStore);
ajaxForm.add(textStore = new Label("textStore", updateString));
push();
}
当我尝试从数据收集器的回调方法中调用“updatePanel”方法时,我得到了这个异常:
ERROR (SelectorManager.run): org.apache.wicket.WicketRuntimeException: No RequestCycle is currently set!
at org.apache.wicket.Component.getRequest(Component.java:1831)
at org.apache.wicket.markup.html.WebPage.dirty(WebPage.java:315)
at org.apache.wicket.Page.dirty(Page.java:288)
at org.apache.wicket.Page.componentRemoved(Page.java:948)
at org.apache.wicket.MarkupContainer.removedComponent(MarkupContainer.java:1422)
at org.apache.wicket.MarkupContainer.remove(MarkupContainer.java:612)
at uk.ac.warwick.collabtex.AsyncCommsPanel.updatePanel(AsyncCommsPanel.java:107)
at uk.ac.warwick.collabtex.Editor$1.updateSuccess(Editor.java:98)