/** * Returns true if the component has been rendered on the browser. A component is considered * rendered if it belongs to a rendered page. * * @return True if the component has been rendered on the browser. */ public boolean isRendered() { return page != null && page.getId() != null; }
@Override protected String getKey(Page item) { return item.getId(); }
/** * Returns the next available component id. * * @return The next available component id. */ private String nextComponentId() { return getId() + "_" + Integer.toHexString(++nextId); }
/** * Creates a proxy for the help viewer with the specified page as owner. * * @param owner Page that will own this proxy. */ public HelpViewerProxy(Page owner) { super(); this.owner = owner; remoteWindowName = "help" + owner.getId(); proxyQueue = new InvocationRequestQueue(remoteWindowName, owner, this, HelpUtil.closeRequest); }
/** * Requests the creation of the remote viewer window, passing it the owner's page id. */ private void startRemoteViewer() { HelpUtil.openWindow(HelpUtil.VIEWER_URL + "?proxy=" + owner.getId(), remoteWindowName); }
protected void initClientRequestMap(Map<String, Object> map) { map.put("pid", session.getPage().getId()); map.put("type", "mock"); }
/** * Initialize the session. If already initialized, this only validates that the page id matches * that of the associated page. Otherwise, it associates the session with the page specified by * the page id. * * @param pageId The page id. * @return True if initialization took place. */ protected boolean _init(String pageId) { if (page != null) { Assert.isTrue(page.getId().equals(pageId), () -> "Unexpected page id: " + pageId); return false; } else { page = PageRegistry.getPage(pageId); return true; } } }
/** * Registers a dynamic resource with this page. * * @param path The virtual path of the resource. * @param resource The resource. If null, any existing resource associated with the virtual page * is removed. */ public void registerResource(String path, Resource resource) { DynamicResourceRegistry.getInstance().registerResource(getId() + "/" + path, resource); }
/** * Remove the session's associated resource registry, if any. * * @see org.fujion.websocket.ISessionLifecycle#onSessionDestroy(org.fujion.websocket.Session) */ @Override public void onSessionDestroy(Session session) { Page page = session.getPage(); String pid = page == null ? "?" : page.getId(); ResourceRegistry registry = registryMap.get(pid); if (registry != null) { registryMap.remove(pid); registry.clear(); } } }
public MockSession(MockServletContext servletContext, MockWebSocketSession socket) { super(servletContext, socket); Page page = Page._create("mockpage"); _init(page.getId()); }
String wsUrl = "ws" + baseUrl.substring(4) + "ws"; String webJarInit = WebJarLocator.getInstance().getWebJarInit(); map.put("pid", page.getId()); map.put("baseUrl", baseUrl); map.put("wsUrl", wsUrl);
/** * Registers/unregisters a component newly attached to this page. * * @param component Component to register/unregister. * @param register If true, register the component. If false, unregister it. */ /*package*/ void registerComponent(BaseComponent component, boolean register) { if (getId() == null) { return; } String id = component.getId(); if (id == null) { id = nextComponentId(); component._setId(id); } if (register) { ids.put(id, component); } else { ids.remove(id); } Event event = new Event(register ? "register" : "unregister", this, component); fireEvent(event); }
/** * Executes the target operation with timings. */ @Override public void run() { watch.start(); ExecutionContext.invoke(page.getId(), () -> { try { target.run(ThreadEx.this); } catch (Throwable e) { exception = e; } }); watch.stop(); ThreadEx.this.done(); }
close(); } else { requestQueue = new InvocationRequestQueue("help" + page.getId(), page, this, HelpUtil.closeRequest); proxyQueue.sendRequest("setRemoteQueue", requestQueue);