/** * Checks whether the given connector has already been initialized in the * browser. The given connector should be registered with this connector * tracker. * * @param connector * the client connector to check * @return <code>true</code> if the initial state has previously been sent * to the browser, <code>false</code> if the client-side doesn't * already know anything about the connector. */ public boolean isClientSideInitialized(ClientConnector connector) { assert connectorIdToConnector.get(connector .getConnectorId()) == connector : "Connector should be registered with this ConnectorTracker"; return !uninitializedConnectors.contains(connector); }
final ClientConnector connector) { Collection<Extension> extensions = connector.getExtensions(); boolean hasComponents = connector instanceof HasComponents; boolean hasExtensions = !extensions.isEmpty();
/** * Finds a UI ancestor of this connector. <code>null</code> is returned if * no UI ancestor is found (typically because the connector is not attached * to a proper hierarchy). * * @return the UI ancestor of this connector, or <code>null</code> if none * is found. */ @Override public UI getUI() { ClientConnector connector = this; while (connector != null) { if (connector instanceof UI) { return (UI) connector; } connector = connector.getParent(); } return null; }
private static String getConnectorResourceBase(String filename, ClientConnector connector) { String uri = ApplicationConstants.APP_PROTOCOL_PREFIX + ApplicationConstants.APP_PATH + '/' + ConnectorResource.CONNECTOR_PATH + '/' + connector.getUI().getUIId() + '/' + connector.getConnectorId() + '/' + encodeFileName(filename); return uri; }
"File upload ignored because the connector for the stream variable was not found"); if (!connector.isConnectorEnabled()) { throw new UploadException("Warning: file upload ignored for " + connector.getConnectorId() + " because the component was disabled"); UI ui = connector.getUI(); boolean forgetVariable = streamToReceiver(session, inputStream, streamVariable, filename, mimeType, contentLength);
for (ClientConnector connector : dirtyVisibleConnectors) { String connectorId = connector.getConnectorId(); try { JsonObject stateJson = connector.encodeState();
ErrorHandler errorHandler = connector.getErrorHandler(); if (errorHandler != null) { return errorHandler; ClientConnector parent = connector.getParent(); if (parent != null) { return findErrorHandler(parent); UI ui = connector.getUI(); if (ui != null) { errorHandler = findErrorHandler(ui.getSession());
.setCurrent(ui); try { if (!connector.handleConnectorRequest(request, response, key)) { return error(request, response, connector.getClass().getSimpleName() + " (" + connector.getConnectorId() + ") did not handle connector request for " + key);
ClientConnector connector = conn; while (connector.getParent() != null) { ++depth; connector = connector.getParent(); connector.beforeClientResponse(!initialized); } catch (RuntimeException e) { manager.handleConnectorRelatedException(connector, e);
@Override public void attach() { markAsDirty(); getUI().getConnectorTracker().registerConnector(this); for (ClientConnector connector : getAllChildrenIterable(this)) { connector.attach(); } fireEvent(new AttachEvent(this)); }
/** * {@inheritDoc} * * <p> * The {@link #getSession()} and {@link #getUI()} methods might return * <code>null</code> after this method is called. * </p> */ @Override public void detach() { for (ClientConnector connector : getAllChildrenIterable(this)) { connector.detach(); } fireEvent(new DetachEvent(this)); getUI().getConnectorTracker().unregisterConnector(this); }
/** * Adds an attach listener to this connector. * * @param listener * The attach listener * @return this (for method chaining) * @see #addAttachListener(com.vaadin.server.ClientConnector.AttachListener) */ public default S withAttachListener(AttachListener listener) { ((ClientConnector) this).addAttachListener(listener); return (S) this; }
/** * Adds a detach listener to this connector. * * @param listener * The detach listener * @return this (for method chaining) * @see #addDetachListener(com.vaadin.server.ClientConnector.DetachListener) */ public default S withDetachListener(DetachListener listener) { ((ClientConnector) this).addDetachListener(listener); return (S) this; } }
/** * @deprecated As of 7.1. See #11411. */ @Deprecated public String getStreamVariableTargetUrl(ClientConnector owner, String name, StreamVariable value) { /* * We will use the same APP/* URI space as ApplicationResources but * prefix url with UPLOAD * * e.g. APP/UPLOAD/[UIID]/[PID]/[NAME]/[SECKEY] * * SECKEY is created on each paint to make URL's unpredictable (to * prevent CSRF attacks). * * NAME and PID from URI forms a key to fetch StreamVariable when * handling post */ String paintableId = owner.getConnectorId(); UI ui = owner.getUI(); int uiId = ui.getUIId(); String key = uiId + "/" + paintableId + "/" + name; ConnectorTracker connectorTracker = ui.getConnectorTracker(); connectorTracker.addStreamVariable(paintableId, name, value); String seckey = connectorTracker.getSeckey(value); return ApplicationConstants.APP_PROTOCOL_PREFIX + ServletPortletHelper.UPLOAD_URL_PREFIX + key + "/" + seckey; }
public JsonObject getDiffState(ClientConnector connector) { assert getConnector(connector.getConnectorId()) == connector; return diffStates.get(connector); }
ClientConnector connector = iterator.next(); assert connector != null; if (connector.getUI() != uI) { diffStates.remove(connector); assert isRemovalSentToClient(connector) : "Connector " + connector + " (id = " + connector.getConnectorId() + ") is no longer visible to the client, but no corresponding hierarchy change was sent."; if (getLogger().isLoggable(Level.FINE)) {
private ClientConnector findFirstVisibleParent(ClientConnector connector) { while (connector != null) { connector = connector.getParent(); if (LegacyCommunicationManager .isConnectorVisibleToClient(connector)) { return connector; } } return null; }
public void setDiffState(ClientConnector connector, JsonObject diffState) { assert getConnector(connector.getConnectorId()) == connector; diffStates.put(connector, diffState); }
/** * Returns {@link #getConnectorString(ClientConnector)} for the connector * and its parent (if it has a parent). * * @param connector * The connector * @return A string describing the connector and its parent */ private String getConnectorAndParentInfo(ClientConnector connector) { String message = getConnectorString(connector); if (connector.getParent() != null) { message += " (parent: " + getConnectorString(connector.getParent()) + ")"; } return message; }
/** * Returns a string with the connector name and id. Useful mostly for * debugging and logging. * * @param connector * The connector * @return A string that describes the connector */ private String getConnectorString(ClientConnector connector) { if (connector == null) { return "(null)"; } String connectorId; try { connectorId = connector.getConnectorId(); } catch (RuntimeException e) { // This happens if the connector is not attached to the application. // SHOULD not happen in this case but theoretically can. connectorId = "@" + Integer.toHexString(connector.hashCode()); } return connector.getClass().getName() + "(" + connectorId + ")"; }