いくつかのパネルがマップに通知し、マップが他のすべてのパネルに通知する場合のように、いくつかのウィケット パネル ストアを別のセッションの静的ハッシュマップに格納しています。例えば:
public class PanelMap{
private static Map<Long, List<MyPanel>> map = new HashMap<Long, List<MyPanel>>();
public static void subscribe(Long id, MyPanel panel){
if (!map.containsKey(id)){
map.put(id, new ArrayList<MyPanel>());
}
map.get(id).add(panel);
}
}
public static void notify(Long id, String notification){
if (map.containsKey(id)){
List<MyPanel> panels = map.get(id);
for(MyPanel panel : panels){
panel.newNotification(notification);
}
}
}
}
パネルでは、newNotification(文字列通知) サーバーにリクエストを送信し、ブラウザでパネルを更新したいと考えています。
public void String newNotification(String notification){
// do some business logic depends on notification
onMyRequest();
}
私はウィケットの振る舞いのソースファイルの中からいくつかの検索AbstractDefaultAjaxBehavior
を行い、次のようにウィケットパネル内で独自の onRequest メソッドを作成しようとしました
private void onMyRequest(){
AjaxRequestTarget target = ((WebApplication)getApplication()).newAjaxRequestTarget(getPage());
target.add( _some_wicket_components_ );
RequestCycle.get().scheduleRequestHandlerAfterCurrent(target);
}
しかし、私がしたのは、Wicket Ajax Debug の Ajax エラーだけです。
Wicket.Ajax.Call.processComponent: Component with id _containerdiv_ was not found while trying to perform markup update.
ERROR: Cannot find element with id: _someComponentIdOnPanel_
(これらのコンポーネントは存在します)
自分のリクエストをサーバーに送信するにはどうすればよいですか (または有効な AjaxRequestTarget を取得してコンポーネントを更新するにはどうすればよいですか?)
更新:セッション間通信が必要です。