package com.vaadin.terminal;
import com.vaadin.shared.JavaScriptExtensionState;
+import com.vaadin.terminal.gwt.client.ApplicationConnection;
import com.vaadin.ui.JavaScriptCallback;
/**
* exception when called. The scheme for conversion between Java types in the
* RPC interface and the JavaScript values that should be passed to the
* functions is described bellow.</li>
+ * <li><code>translateVaadinUri(uri)</code> - Translates a Vaadin URI to a URL
+ * that can be used in the browser. This is just way of accessing
+ * {@link ApplicationConnection#translateVaadinUri(String)}</li>
* </ul>
* The connector wrapper also supports these special functions:
* <ul>
private JavaScriptObject getConnectorWrapper() {
if (connectorWrapper == null) {
- connectorWrapper = createConnectorWrapper(this, nativeState,
- rpcMap, connector.getConnectorId(), rpcObjects);
+ connectorWrapper = createConnectorWrapper(this,
+ connector.getConnection(), nativeState, rpcMap,
+ connector.getConnectorId(), rpcObjects);
}
return connectorWrapper;
}-*/;
private static native JavaScriptObject createConnectorWrapper(
- JavaScriptConnectorHelper h, JavaScriptObject nativeState,
- JavaScriptObject registeredRpc, String connectorId,
- Map<String, JavaScriptObject> rpcObjects)
+ JavaScriptConnectorHelper h, ApplicationConnection c,
+ JavaScriptObject nativeState, JavaScriptObject registeredRpc,
+ String connectorId, Map<String, JavaScriptObject> rpcObjects)
/*-{
return {
'getConnectorId': function() {
}
registeredRpc[iface].push(rpcHandler);
},
+ 'translateVaadinUri': $entry(function(uri) {
+ return c.@com.vaadin.terminal.gwt.client.ApplicationConnection::translateVaadinUri(Ljava/lang/String;)(uri);
+ }),
};
}-*/;
import com.vaadin.shared.ui.JavaScriptComponentState;
import com.vaadin.terminal.JavaScriptCallbackHelper;
+import com.vaadin.terminal.gwt.client.ApplicationConnection;
import com.vaadin.terminal.gwt.client.ui.JavaScriptWidget;
/**
* exception when called. The scheme for conversion between Java types in the
* RPC interface and the JavaScript values that should be passed to the
* functions is described bellow.</li>
+ * <li><code>translateVaadinUri(uri)</code> - Translates a Vaadin URI to a URL
+ * that can be used in the browser. This is just way of accessing
+ * {@link ApplicationConnection#translateVaadinUri(String)}</li>
* </ul>
* The connector wrapper also supports these special functions:
* <ul>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head profile="http://selenium-ide.openqa.org/profiles/test-case">
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<link rel="selenium.base" href="" />
+<title>New Test</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="3">New Test</td></tr>
+</thead><tbody>
+<tr>
+ <td>open</td>
+ <td>/run/com.vaadin.tests.components.javascriptcomponent.BasicJavaScriptComponent?restartApplication</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentsjavascriptcomponentBasicJavaScriptComponent::/VVerticalLayout[0]/VVerticalLayout[0]/VVerticalLayout[0]/VLabel[0]</td>
+ <td>3. Got callback message: Callback message processed</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentsjavascriptcomponentBasicJavaScriptComponent::/VVerticalLayout[0]/VVerticalLayout[0]/VVerticalLayout[0]/VLabel[1]</td>
+ <td>2. Got RPC message: RPC message processed</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentsjavascriptcomponentBasicJavaScriptComponent::/VVerticalLayout[0]/VVerticalLayout[0]/VVerticalLayout[0]/VLabel[2]</td>
+ <td>1. Parent ids checked</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentsjavascriptcomponentBasicJavaScriptComponent::/VVerticalLayout[0]/VVerticalLayout[0]/domChild[1]/domChild[0]/domChild[0]</td>
+ <td>Component caption</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentsjavascriptcomponentBasicJavaScriptComponent::/VVerticalLayout[0]/VVerticalLayout[0]/JavaScriptWidget[0]/domChild[0]</td>
+ <td>4. Url: /run/com.vaadin.tests.components.javascriptcomponent.BasicJavaScriptComponent/APP/1/test</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentsjavascriptcomponentBasicJavaScriptComponent::/VVerticalLayout[0]/VVerticalLayout[0]/JavaScriptWidget[0]/domChild[1]</td>
+ <td>3. State message: Second state message</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentsjavascriptcomponentBasicJavaScriptComponent::/VVerticalLayout[0]/VVerticalLayout[0]/JavaScriptWidget[0]/domChild[2]</td>
+ <td>2. State message: First state message</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentsjavascriptcomponentBasicJavaScriptComponent::/VVerticalLayout[0]/VVerticalLayout[0]/JavaScriptWidget[0]/domChild[3]</td>
+ <td>1. Parent element className: v-verticallayout v-connector v-has-width</td>
+</tr>
+
+</tbody></table>
+</body>
+</html>
import com.vaadin.external.json.JSONException;
import com.vaadin.shared.communication.ClientRpc;
import com.vaadin.shared.communication.ServerRpc;
+import com.vaadin.shared.communication.URLReference;
import com.vaadin.shared.ui.JavaScriptComponentState;
+import com.vaadin.terminal.ClassResource;
import com.vaadin.terminal.WrappedRequest;
+import com.vaadin.terminal.gwt.server.ResourceReference;
import com.vaadin.tests.components.AbstractTestRoot;
import com.vaadin.tests.util.Log;
import com.vaadin.ui.AbstractJavaScriptComponent;
public static class TestState extends JavaScriptComponentState {
private List<String> messages = new ArrayList<String>();
+ private URLReference url;
public List<String> getMessages() {
return messages;
public void setMessages(List<String> messages) {
this.messages = messages;
}
+
+ public URLReference getUrl() {
+ return url;
+ }
+
+ public void setUrl(URLReference url) {
+ this.url = url;
+ }
}
@JavaScript("BasicJavaScriptComponentConnector.js")
.setMessages(
Arrays.asList("First state message",
"Second state message"));
+ ClassResource resource = new ClassResource("test",
+ BasicJavaScriptComponent.this.getApplication());
+ getState().setUrl(new ResourceReference(resource));
}
@Override
for(var i = 0; i < messages.length; i++) {
log("State message: " + messages[i]);
}
+
+ var url = this.getState().url;
+ log("Url: " + this.translateVaadinUri(url.uRL)); //Strange format, see #9210
}
this.registerRpc({