From: Leif Åstrand Date: Fri, 15 Jun 2012 10:56:10 +0000 (+0300) Subject: Add API for getting the parent connector's id (#8888) X-Git-Tag: 7.0.0.alpha3~113^2~2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=ae2a42dd038b03c5b3dc69c4574bc887bfc8abc2;p=vaadin-framework.git Add API for getting the parent connector's id (#8888) --- diff --git a/src/com/vaadin/terminal/gwt/client/JavaScriptConnectorHelper.java b/src/com/vaadin/terminal/gwt/client/JavaScriptConnectorHelper.java index 006105fed6..bd62a759cb 100644 --- a/src/com/vaadin/terminal/gwt/client/JavaScriptConnectorHelper.java +++ b/src/com/vaadin/terminal/gwt/client/JavaScriptConnectorHelper.java @@ -173,6 +173,9 @@ public class JavaScriptConnectorHelper { 'getConnectorId': function() { return connectorId; }, + 'getParentId': $entry(function(connectorId) { + return h.@com.vaadin.terminal.gwt.client.JavaScriptConnectorHelper::getParentId(Ljava/lang/String;)(connectorId); + }), 'getState': function() { return nativeState; }, @@ -208,13 +211,21 @@ public class JavaScriptConnectorHelper { }); }-*/; - private Element getWidgetElement(String connectorId) { - if (connectorId == null) { - connectorId = connector.getConnectorId(); + private String getParentId(String connectorId) { + ServerConnector target = getConnector(connectorId); + if (target == null) { + return null; } + ServerConnector parent = target.getParent(); + if (parent == null) { + return null; + } else { + return parent.getConnectorId(); + } + } - ServerConnector target = ConnectorMap.get(connector.getConnection()) - .getConnector(connectorId); + private Element getWidgetElement(String connectorId) { + ServerConnector target = getConnector(connectorId); if (target instanceof ComponentConnector) { return ((ComponentConnector) target).getWidget().getElement(); } else { @@ -222,6 +233,15 @@ public class JavaScriptConnectorHelper { } } + private ServerConnector getConnector(String connectorId) { + if (connectorId == null || connectorId.length() == 0) { + return connector; + } + + return ConnectorMap.get(connector.getConnection()) + .getConnector(connectorId); + } + private void fireRpc(String iface, String method, JsArray arguments) { if (iface == null) {