Two help desk chats inside this Wicket page: one rendered by React, one by Svelte. They are islands: the browser renders them, the server keeps them. Wicket answers both, in Java on the server: it matches the words of a question against what it knows of the widgets, no AI. It keeps the conversation, so both chats show the same one.
They are built with Wicket Islands (apache/wicket#1834, proposed for Wicket 12), ported to Wicket 11 (apache/wicket#2057), with its adapters of React and Svelte. Three of its ideas to try:
- A promise per call. A chat asks with
call('ask', question), an Ajax request of the page. Wicket answers in the same Ajax response that replaces its components: both chats, with the new conversation as their props, and Wicket's panel below them. The promise resolves only once they were replaced; the chat then tells how long it took and how many components came with the answer. A question refused rejects the promise with a kind: invalid (an empty question), forbidden (ask for the admin password), error (type /error) or network. - Islands that live through a re-render. Each island has a key. Type something in a chat without sending it, then Re-render the container: Wicket replaces the markup around the chats, and the runtime moves each living chat into its new host and gives it its new props. The draft stays; the focus and the scroll position, which moving takes away, the chats put back themselves. Props updated counts up, mounted at stays. Replace the islands puts new components in their place, with new keys: the chats mount anew and the draft is gone, but not the conversation, which the server keeps.
- Props as JSON data. Each host holds its props in a
<script type="application/json">, which no browser runs, and one runtime mounts every host it finds. No init script per island, and nothing anybody typed ever goes into a script.
Wicket asks too, from its own form: the chats get the answer as new props. The React and the Svelte chats come in modules of their own, which share one islands runtime.