/** * Perform a client invocation on the active page. * * @param invocation The client invocation. */ public static void invoke(ClientInvocation invocation) { ExecutionContext.getPage().invoke(invocation); }
/** * Invoke a function on the client. * * @param function Name of the function to invoke. * @param callback Optional callback for invocation result. * @param args Arguments to pass to the function. */ public static void invoke(String function, IResponseCallback<?> callback, Object... args) { ExecutionContext.getPage().invoke(null, function, callback, args); }
/** * Echo an event. This is similar to a post, but defers event delivery until the client responds * to a dummy invocation. It simulates an event roundtrip from server to client and back, though * the event itself never leaves the server. * * @param event The event to send. If the event's designated target is null, the event is sent * to the page in the current execution context. */ public static void echo(Event event) { event.getPage().invoke("id", (response) -> { send(event); }); }
@Override public void handleRequest(ClientRequest request) { Page page = request.getPage(); PageDefinition pageDefinition = PageDefinitionCache.getInstance().get(page.getSrc()); Synchronizer synchronizer = request.getSession().getSynchronizer(); synchronizer.startQueueing(); Page._init(page, request, synchronizer); Sessions.getInstance().notifyLifecycleListeners(request.getSession(), true); try { page.invoke("beforeInitialize", clientOptionMap); pageDefinition.materialize(page); page.invoke("afterInitialize"); page.fireEvent("afterInitialize"); } catch (Exception e) { synchronizer.clear(); throw new SessionInitException(e); } finally { synchronizer.stopQueueing(); } }