sina
sina

Reputation: 1829

Apache Wicket: Communicate between independent pages of same application

On my wicket page I have a link that opens a second page in another tab/new window.

<a href="/MySecondPage" target="_blank">Click here for second window</a>

These windows are meant to be used in parallel (e.g. in a two-monitor-environment). But I don't want to spread out different menu entries over both screens, so I want all menu entries to stay on MyFirstPage, even if they should influence MySecondPage only.

My ultimate goal is to click a menu entry on MyFirstPage that results in displaying a new Component on MySecondPage. Is this even possible? How can I obtain a java-reference of MySecondPage inside MyFirstPage or establish some other sort of communication? Everything I found while researching only applied to modal windows or Wicket 1.4, but MySecondPage is not modal.

Upvotes: 1

Views: 1020

Answers (2)

mrak
mrak

Reputation: 2906

There is WebSocket support in Wicket 6: http://wicketinaction.com/2012/07/wicket-6-native-websockets/

Basically you need to add WebSocketBehavior to the page to make it available for messages from the server.

On the other hand, you can send messages to the server via Wicket.WebSocket.send("A message sent by the client");

I have never tired it but it sounds very promising.

Upvotes: 0

Robert Niestroj
Robert Niestroj

Reputation: 16131

Maybe wicket's event bus is an option, see: http://code.google.com/p/wicket-guide/downloads/list - Chapter 15.3 Wicket events infrastructure

You could send the event in MyFirstPage , receive it in your Session or Application and there send it to MySecondPage. Session and Application implement IEventSink: http://ci.apache.org/projects/wicket/apidocs/6.x/org/apache/wicket/event/IEventSink.html

Upvotes: 3

Related Questions