Meriem Selmi
Meriem Selmi

Reputation: 51

How can i send an event from a session in wicket?

I have an AuthenticatedWebSession which stores Room and Home information.

  1. A component sends a Breadth event to the session (RoomChangedEvent)
  2. the session retrieves all the new data related to Room and store it (to the session)
  3. all pages and components eventually receive this event afterwards, and some of them will update their states (based on the new session data).

BUT, while retrieving Room's information the session discovers that Home changed too, and decides to send a HomeChangedEvent, so that, other components will update their states. How can i do that ?

Upvotes: 0

Views: 289

Answers (1)

martin-g
martin-g

Reputation: 17533

The update of the other pages makes sense only if you push the update to the browsers as well. Otherwise every page (or better a base page) could check whether there is something new in the Session in its #onConfigure() and update itself accordingly.

If you want to update all pages immediately (with server push) then take a look at Wicket Native WebSocket module (https://ci.apache.org/projects/wicket/guide/7.x/guide/nativewebsockets.html). By using WebSocketRegistry.Holder.get(application).getConnections() you can easily get all active pages with opened WebSocket connection.

Upvotes: 1

Related Questions