summaryrefslogtreecommitdiffstats
path: root/client/src/com
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/com')
-rw-r--r--client/src/com/vaadin/client/ApplicationConnection.java31
-rw-r--r--client/src/com/vaadin/client/ComponentConnector.java12
-rw-r--r--client/src/com/vaadin/client/JavaScriptConnectorHelper.java7
-rw-r--r--client/src/com/vaadin/client/Util.java17
-rw-r--r--client/src/com/vaadin/client/communication/JavaScriptMethodInvocation.java34
-rw-r--r--client/src/com/vaadin/client/extensions/javascriptmanager/JavaScriptManagerConnector.java4
-rw-r--r--client/src/com/vaadin/client/ui/AbstractComponentConnector.java9
-rw-r--r--client/src/com/vaadin/client/ui/VUI.java2
-rw-r--r--client/src/com/vaadin/client/ui/richtextarea/RichTextAreaConnector.java7
-rw-r--r--client/src/com/vaadin/client/ui/textfield/TextFieldConnector.java5
10 files changed, 116 insertions, 12 deletions
diff --git a/client/src/com/vaadin/client/ApplicationConnection.java b/client/src/com/vaadin/client/ApplicationConnection.java
index 2e8387c5da..63dfde795b 100644
--- a/client/src/com/vaadin/client/ApplicationConnection.java
+++ b/client/src/com/vaadin/client/ApplicationConnection.java
@@ -65,6 +65,7 @@ import com.vaadin.client.ApplicationConfiguration.ErrorMessage;
import com.vaadin.client.ResourceLoader.ResourceLoadEvent;
import com.vaadin.client.ResourceLoader.ResourceLoadListener;
import com.vaadin.client.communication.HasJavaScriptConnectorHelper;
+import com.vaadin.client.communication.JavaScriptMethodInvocation;
import com.vaadin.client.communication.JsonDecoder;
import com.vaadin.client.communication.JsonEncoder;
import com.vaadin.client.communication.RpcManager;
@@ -2459,9 +2460,7 @@ public class ApplicationConnection {
}
private boolean isJavascriptRpc(MethodInvocation invocation) {
- String connectorId = invocation.getConnectorId();
- ServerConnector connector = connectorMap.getConnector(connectorId);
- return connector instanceof HasJavaScriptConnectorHelper;
+ return invocation instanceof JavaScriptMethodInvocation;
}
private boolean isLegacyVariableChange(MethodInvocation invocation) {
@@ -3271,4 +3270,30 @@ public class ApplicationConnection {
GwtEvent.Type<H> type, H handler) {
return eventBus.addHandler(type, handler);
}
+
+ /**
+ * Calls {@link ComponentConnector#flush()} on the active connector. Does
+ * nothing if there is no active (focused) connector.
+ */
+ public void flushActiveConnector() {
+ ComponentConnector activeConnector = getActiveConnector();
+ if (activeConnector == null) {
+ return;
+ }
+ activeConnector.flush();
+ }
+
+ /**
+ * Gets the active connector for focused element in browser.
+ *
+ * @return Connector for focused element or null.
+ */
+ private ComponentConnector getActiveConnector() {
+ Element focusedElement = Util.getFocusedElement();
+ if (focusedElement == null) {
+ return null;
+ }
+ return Util.getConnectorForElement(this, getUIConnector().getWidget(),
+ focusedElement);
+ }
}
diff --git a/client/src/com/vaadin/client/ComponentConnector.java b/client/src/com/vaadin/client/ComponentConnector.java
index 63e55153b6..db3cc25c56 100644
--- a/client/src/com/vaadin/client/ComponentConnector.java
+++ b/client/src/com/vaadin/client/ComponentConnector.java
@@ -127,4 +127,16 @@ public interface ComponentConnector extends ServerConnector {
*/
public TooltipInfo getTooltipInfo(Element element);
+ /**
+ * Called for the active (focused) connector when a situation occurs that
+ * the focused connector might have buffered changes which need to be
+ * processed before other activity takes place.
+ * <p>
+ * This is currently called when the user changes the fragment using the
+ * back/forward button in the browser and allows the focused field to submit
+ * its value to the server before the fragment change event takes place.
+ * </p>
+ */
+ public void flush();
+
}
diff --git a/client/src/com/vaadin/client/JavaScriptConnectorHelper.java b/client/src/com/vaadin/client/JavaScriptConnectorHelper.java
index b275cd0a68..73752e4ddb 100644
--- a/client/src/com/vaadin/client/JavaScriptConnectorHelper.java
+++ b/client/src/com/vaadin/client/JavaScriptConnectorHelper.java
@@ -27,6 +27,7 @@ import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.core.client.JsArray;
import com.google.gwt.json.client.JSONArray;
import com.google.gwt.user.client.Element;
+import com.vaadin.client.communication.JavaScriptMethodInvocation;
import com.vaadin.client.communication.StateChangeEvent;
import com.vaadin.client.communication.StateChangeEvent.StateChangeHandler;
import com.vaadin.shared.JavaScriptConnectorState;
@@ -258,8 +259,8 @@ public class JavaScriptConnectorHelper {
parameters[i] = argumentsArray.get(i);
}
connector.getConnection().addMethodInvocationToQueue(
- new MethodInvocation(connector.getConnectorId(), iface, method,
- parameters), false, false);
+ new JavaScriptMethodInvocation(connector.getConnectorId(),
+ iface, method, parameters), false, false);
}
private String findWildcardInterface(String method) {
@@ -286,7 +287,7 @@ public class JavaScriptConnectorHelper {
}
private void fireCallback(String name, JsArray<JavaScriptObject> arguments) {
- MethodInvocation invocation = new MethodInvocation(
+ MethodInvocation invocation = new JavaScriptMethodInvocation(
connector.getConnectorId(),
"com.vaadin.ui.JavaScript$JavaScriptCallbackRpc", "call",
new Object[] { name, new JSONArray(arguments) });
diff --git a/client/src/com/vaadin/client/Util.java b/client/src/com/vaadin/client/Util.java
index 0df8bfb90f..3d6f64d4d5 100644
--- a/client/src/com/vaadin/client/Util.java
+++ b/client/src/com/vaadin/client/Util.java
@@ -1059,11 +1059,11 @@ public class Util {
}
/**
- * Gets the currently focused element for Internet Explorer.
+ * Gets the currently focused element.
*
- * @return The currently focused element
+ * @return The active element or null if no active element could be found.
*/
- public native static Element getIEFocusedElement()
+ public native static Element getFocusedElement()
/*-{
if ($wnd.document.activeElement) {
return $wnd.document.activeElement;
@@ -1072,6 +1072,17 @@ public class Util {
return null;
}-*/
;
+
+ /**
+ * Gets the currently focused element for Internet Explorer.
+ *
+ * @return The currently focused element
+ * @deprecated Use #getFocusedElement instead
+ */
+ @Deprecated
+ public static Element getIEFocusedElement() {
+ return getFocusedElement();
+ }
/**
* Kind of stronger version of isAttached(). In addition to std isAttached,
diff --git a/client/src/com/vaadin/client/communication/JavaScriptMethodInvocation.java b/client/src/com/vaadin/client/communication/JavaScriptMethodInvocation.java
new file mode 100644
index 0000000000..00f563e333
--- /dev/null
+++ b/client/src/com/vaadin/client/communication/JavaScriptMethodInvocation.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2012 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package com.vaadin.client.communication;
+
+import com.vaadin.shared.communication.MethodInvocation;
+
+/**
+ * A {@link MethodInvocation} that originates from JavaScript. This means that
+ * there might not be any type information available on the client.
+ *
+ * @author Vaadin Ltd
+ * @since 7.0.0
+ */
+public class JavaScriptMethodInvocation extends MethodInvocation {
+
+ public JavaScriptMethodInvocation(String connectorId, String interfaceName,
+ String methodName, Object[] parameters) {
+ super(connectorId, interfaceName, methodName, parameters);
+ }
+}
diff --git a/client/src/com/vaadin/client/extensions/javascriptmanager/JavaScriptManagerConnector.java b/client/src/com/vaadin/client/extensions/javascriptmanager/JavaScriptManagerConnector.java
index 2550fce208..078e19f73b 100644
--- a/client/src/com/vaadin/client/extensions/javascriptmanager/JavaScriptManagerConnector.java
+++ b/client/src/com/vaadin/client/extensions/javascriptmanager/JavaScriptManagerConnector.java
@@ -24,8 +24,8 @@ import com.google.gwt.core.client.JsArray;
import com.google.gwt.json.client.JSONArray;
import com.vaadin.client.ServerConnector;
import com.vaadin.client.communication.StateChangeEvent;
+import com.vaadin.client.communication.JavaScriptMethodInvocation;
import com.vaadin.client.extensions.AbstractExtensionConnector;
-import com.vaadin.shared.communication.MethodInvocation;
import com.vaadin.shared.extension.javascriptmanager.ExecuteJavaScriptRpc;
import com.vaadin.shared.extension.javascriptmanager.JavaScriptManagerState;
import com.vaadin.shared.ui.Connect;
@@ -123,7 +123,7 @@ public class JavaScriptManagerConnector extends AbstractExtensionConnector {
* because of the JSONArray parameter
*/
getConnection().addMethodInvocationToQueue(
- new MethodInvocation(getConnectorId(),
+ new JavaScriptMethodInvocation(getConnectorId(),
"com.vaadin.ui.JavaScript$JavaScriptCallbackRpc",
"call", parameters), false, false);
}
diff --git a/client/src/com/vaadin/client/ui/AbstractComponentConnector.java b/client/src/com/vaadin/client/ui/AbstractComponentConnector.java
index f8088d63a2..2c599743e4 100644
--- a/client/src/com/vaadin/client/ui/AbstractComponentConnector.java
+++ b/client/src/com/vaadin/client/ui/AbstractComponentConnector.java
@@ -426,4 +426,13 @@ public abstract class AbstractComponentConnector extends AbstractConnector
protected String getIcon() {
return getResourceUrl(ComponentConstants.ICON_RESOURCE);
}
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.client.ComponentConnector#flush()
+ */
+ public void flush() {
+ // No generic implementation. Override if needed
+ }
}
diff --git a/client/src/com/vaadin/client/ui/VUI.java b/client/src/com/vaadin/client/ui/VUI.java
index cbfbda813e..a21397c060 100644
--- a/client/src/com/vaadin/client/ui/VUI.java
+++ b/client/src/com/vaadin/client/ui/VUI.java
@@ -129,8 +129,10 @@ public class VUI extends SimplePanel implements ResizeHandler,
String newFragment = event.getValue();
// Send the location to the server if the fragment has changed
+ // and flush active connectors in UI.
if (!newFragment.equals(currentFragment) && connection != null) {
currentFragment = newFragment;
+ connection.flushActiveConnector();
connection.updateVariable(id, UIConstants.LOCATION_VARIABLE,
Window.Location.getHref(), true);
}
diff --git a/client/src/com/vaadin/client/ui/richtextarea/RichTextAreaConnector.java b/client/src/com/vaadin/client/ui/richtextarea/RichTextAreaConnector.java
index afcf479499..8875fc421b 100644
--- a/client/src/com/vaadin/client/ui/richtextarea/RichTextAreaConnector.java
+++ b/client/src/com/vaadin/client/ui/richtextarea/RichTextAreaConnector.java
@@ -75,12 +75,17 @@ public class RichTextAreaConnector extends AbstractFieldConnector implements
@Override
public void onBeforeShortcutAction(Event e) {
- getWidget().synchronizeContentToServer();
+ flush();
}
@Override
public VRichTextArea getWidget() {
return (VRichTextArea) super.getWidget();
+ }
+
+ @Override
+ public void flush() {
+ getWidget().synchronizeContentToServer();
};
}
diff --git a/client/src/com/vaadin/client/ui/textfield/TextFieldConnector.java b/client/src/com/vaadin/client/ui/textfield/TextFieldConnector.java
index c653b06cf9..bedcd5f936 100644
--- a/client/src/com/vaadin/client/ui/textfield/TextFieldConnector.java
+++ b/client/src/com/vaadin/client/ui/textfield/TextFieldConnector.java
@@ -114,6 +114,11 @@ public class TextFieldConnector extends AbstractFieldConnector implements
@Override
public void onBeforeShortcutAction(Event e) {
+ flush();
+ }
+
+ @Override
+ public void flush() {
getWidget().valueChange(false);
}