好了开始吧。这是我的第一个wicket应用程序,我正在尝试使用using面板示例集成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)发布于 2012-03-26 01:16:06
欢迎来到异步世界:-) ThreadLocals (应用程序、会话和ThreadLocal)仅在http请求线程(也称为工作线程)的处理过程中可用。因此有两个问题: 1)启动你自己的线程,你会丢失ThreadLocal;2)即使你导出了它们,当你的任务完成时,响应也有可能已经关闭。我不确定IcePush是如何工作的,但我认为这是最好的选择--提交任务,在应用程序中保留对它的引用(例如地图),然后启动一个ajax计时器行为,它会定期询问futureTask.isDone(),当它返回true时,是否进行所需的层次结构更改(我在堆栈跟踪中看到了对MarkupContainer#remove()的调用)。
https://stackoverflow.com/questions/9842788
复制相似问题