summaryrefslogtreecommitdiffstats
path: root/server/src
diff options
context:
space:
mode:
Diffstat (limited to 'server/src')
-rw-r--r--server/src/com/vaadin/data/util/AbstractProperty.java18
-rw-r--r--server/src/com/vaadin/data/util/IndexedContainer.java18
-rw-r--r--server/src/com/vaadin/data/util/sqlcontainer/ColumnProperty.java18
-rw-r--r--server/src/com/vaadin/event/ActionManager.java29
-rw-r--r--server/src/com/vaadin/event/ShortcutAction.java45
-rw-r--r--server/src/com/vaadin/server/AbstractClientConnector.java5
-rw-r--r--server/src/com/vaadin/server/CommunicationManager.java5
-rw-r--r--server/src/com/vaadin/server/DefaultUIProvider.java8
-rw-r--r--server/src/com/vaadin/server/GAEVaadinServlet.java15
-rw-r--r--server/src/com/vaadin/server/GlobalResourceHandler.java2
-rw-r--r--server/src/com/vaadin/server/VaadinService.java6
-rw-r--r--server/src/com/vaadin/server/VaadinServlet.java30
-rw-r--r--server/src/com/vaadin/server/VaadinServletService.java6
-rw-r--r--server/src/com/vaadin/server/VaadinServletSession.java57
-rw-r--r--server/src/com/vaadin/server/WrappedHttpSession.java5
-rw-r--r--server/src/com/vaadin/server/WrappedPortletSession.java5
-rw-r--r--server/src/com/vaadin/server/WrappedSession.java7
-rw-r--r--server/src/com/vaadin/ui/Button.java9
-rw-r--r--server/src/com/vaadin/ui/Label.java2
19 files changed, 175 insertions, 115 deletions
diff --git a/server/src/com/vaadin/data/util/AbstractProperty.java b/server/src/com/vaadin/data/util/AbstractProperty.java
index 76d47039d0..aefe00ad32 100644
--- a/server/src/com/vaadin/data/util/AbstractProperty.java
+++ b/server/src/com/vaadin/data/util/AbstractProperty.java
@@ -18,6 +18,7 @@ package com.vaadin.data.util;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedList;
+import java.util.logging.Logger;
import com.vaadin.data.Property;
@@ -78,9 +79,17 @@ public abstract class AbstractProperty<T> implements Property<T>,
@Deprecated
@Override
public String toString() {
- throw new UnsupportedOperationException(
- "Use Property.getValue() instead of " + getClass()
- + ".toString()");
+ getLogger()
+ .warning(
+ "You are using Property.toString() instead of getValue() to get the value for a "
+ + getClass().getSimpleName()
+ + ". This will not be supported starting from Vaadin 7.1 "
+ + "(your debugger might call toString() and cause this message to appear).");
+ T v = getValue();
+ if (v == null) {
+ return null;
+ }
+ return v.toString();
}
/* Events */
@@ -277,4 +286,7 @@ public abstract class AbstractProperty<T> implements Property<T>,
return Collections.EMPTY_LIST;
}
+ private static Logger getLogger() {
+ return Logger.getLogger(AbstractProperty.class.getName());
+ }
}
diff --git a/server/src/com/vaadin/data/util/IndexedContainer.java b/server/src/com/vaadin/data/util/IndexedContainer.java
index e957d958a9..7273b28b66 100644
--- a/server/src/com/vaadin/data/util/IndexedContainer.java
+++ b/server/src/com/vaadin/data/util/IndexedContainer.java
@@ -28,6 +28,7 @@ import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import java.util.logging.Logger;
import com.vaadin.data.Container;
import com.vaadin.data.Item;
@@ -961,8 +962,21 @@ public class IndexedContainer extends
@Deprecated
@Override
public String toString() {
- throw new UnsupportedOperationException(
- "Use Property.getValue() instead of IndexedContainerProperty.toString()");
+ getLogger()
+ .warning(
+ "You are using IndexedContainerProperty.toString() instead of getValue() to get the value for a "
+ + getClass().getSimpleName()
+ + ". This will not be supported starting from Vaadin 7.1 "
+ + "(your debugger might call toString() and cause this message to appear).");
+ Object v = getValue();
+ if (v == null) {
+ return null;
+ }
+ return v.toString();
+ }
+
+ private Logger getLogger() {
+ return Logger.getLogger(IndexedContainerProperty.class.getName());
}
/**
diff --git a/server/src/com/vaadin/data/util/sqlcontainer/ColumnProperty.java b/server/src/com/vaadin/data/util/sqlcontainer/ColumnProperty.java
index 6e5ba0dc57..bd6b1a75bf 100644
--- a/server/src/com/vaadin/data/util/sqlcontainer/ColumnProperty.java
+++ b/server/src/com/vaadin/data/util/sqlcontainer/ColumnProperty.java
@@ -18,6 +18,7 @@ package com.vaadin.data.util.sqlcontainer;
import java.sql.Date;
import java.sql.Time;
import java.sql.Timestamp;
+import java.util.logging.Logger;
import com.vaadin.data.Property;
import com.vaadin.data.util.converter.Converter.ConversionException;
@@ -261,8 +262,21 @@ final public class ColumnProperty implements Property {
@Deprecated
@Override
public String toString() {
- throw new UnsupportedOperationException(
- "Use ColumnProperty.getValue() instead of ColumnProperty.toString()");
+ getLogger()
+ .warning(
+ "You are using ColumnProperty.toString() instead of getValue() to get the value for a "
+ + getClass().getSimpleName()
+ + ". This will not be supported starting from Vaadin 7.1 "
+ + "(your debugger might call toString() and cause this message to appear).");
+ Object v = getValue();
+ if (v == null) {
+ return null;
+ }
+ return v.toString();
+ }
+
+ private static Logger getLogger() {
+ return Logger.getLogger(ColumnProperty.class.getName());
}
public void setOwner(RowItem owner) {
diff --git a/server/src/com/vaadin/event/ActionManager.java b/server/src/com/vaadin/event/ActionManager.java
index 85a1bf0f12..50bb2f8dad 100644
--- a/server/src/com/vaadin/event/ActionManager.java
+++ b/server/src/com/vaadin/event/ActionManager.java
@@ -24,6 +24,7 @@ import com.vaadin.server.KeyMapper;
import com.vaadin.server.PaintException;
import com.vaadin.server.PaintTarget;
import com.vaadin.server.VariableOwner;
+import com.vaadin.shared.ui.ShortCutConstants;
import com.vaadin.ui.Component;
/**
@@ -187,14 +188,28 @@ public class ActionManager implements Action.Container, Action.Handler,
}
if (a instanceof ShortcutAction) {
final ShortcutAction sa = (ShortcutAction) a;
- paintTarget.addAttribute("kc", sa.getKeyCode());
+ paintTarget.addAttribute(
+ ShortCutConstants.ACTION_SHORTCUT_KEY_ATTRIBUTE,
+ sa.getKeyCode());
final int[] modifiers = sa.getModifiers();
if (modifiers != null) {
final String[] smodifiers = new String[modifiers.length];
for (int i = 0; i < modifiers.length; i++) {
smodifiers[i] = String.valueOf(modifiers[i]);
}
- paintTarget.addAttribute("mk", smodifiers);
+ paintTarget
+ .addAttribute(
+ ShortCutConstants.ACTION_MODIFIER_KEYS_ATTRIBUTE,
+ smodifiers);
+ }
+ if (sa.getTarget() != null) {
+ paintTarget.addAttribute(
+ ShortCutConstants.ACTION_TARGET_ATTRIBUTE,
+ sa.getTarget());
+ paintTarget
+ .addAttribute(
+ ShortCutConstants.ACTION_TARGET_ACTION_ATTRIBUTE,
+ sa.getTargetAction());
}
}
paintTarget.endTag("action");
@@ -212,10 +227,14 @@ public class ActionManager implements Action.Container, Action.Handler,
}
public void handleActions(Map<String, Object> variables, Container sender) {
- if (variables.containsKey("action") && actionMapper != null) {
- final String key = (String) variables.get("action");
+ if (variables
+ .containsKey(ShortCutConstants.ACTION_TARGET_ACTION_VARIABLE)
+ && actionMapper != null) {
+ final String key = (String) variables
+ .get(ShortCutConstants.ACTION_TARGET_ACTION_VARIABLE);
final Action action = actionMapper.get(key);
- final Object target = variables.get("actiontarget");
+ final Object target = variables
+ .get(ShortCutConstants.ACTION_TARGET_VARIABLE);
if (action != null) {
handleAction(action, sender, target);
}
diff --git a/server/src/com/vaadin/event/ShortcutAction.java b/server/src/com/vaadin/event/ShortcutAction.java
index b1d14b15fe..9d13d41b9f 100644
--- a/server/src/com/vaadin/event/ShortcutAction.java
+++ b/server/src/com/vaadin/event/ShortcutAction.java
@@ -21,6 +21,7 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import com.vaadin.server.Resource;
+import com.vaadin.ui.Component;
import com.vaadin.ui.ComponentContainer;
import com.vaadin.ui.Panel;
import com.vaadin.ui.Window;
@@ -57,6 +58,10 @@ public class ShortcutAction extends Action {
private final int[] modifiers;
+ private Component target;
+
+ private String targetAction;
+
/**
* Creates a shortcut that reacts to the given {@link KeyCode} and
* (optionally) {@link ModifierKey}s. <br/>
@@ -237,6 +242,46 @@ public class ShortcutAction extends Action {
}
/**
+ * Set the target for the shortcut action. If the target widget on the
+ * client side implements {@link ShortcutActionTarget} it will be notified
+ * of the action before the action is communicated to the server side
+ *
+ * @param target
+ * The component which will be thet target of the action
+ */
+ public void setTarget(Component target) {
+ this.target = target;
+ }
+
+ /**
+ * Get the target of the shortcut action
+ */
+ public Component getTarget() {
+ return target;
+ }
+
+ /**
+ * Get the action string that is given to the {@link ShortcutActionTarget}
+ * on the client side
+ *
+ * @return
+ */
+ public String getTargetAction() {
+ return targetAction;
+ }
+
+ /**
+ * Set the action string that is give to the {@link ShortcutActionTarget} on
+ * the client side
+ *
+ * @param targetAction
+ * The target action string
+ */
+ public void setTargetAction(String targetAction) {
+ this.targetAction = targetAction;
+ }
+
+ /**
* Key codes that can be used for shortcuts
*
*/
diff --git a/server/src/com/vaadin/server/AbstractClientConnector.java b/server/src/com/vaadin/server/AbstractClientConnector.java
index eb59cbe5fc..1f0d3049b5 100644
--- a/server/src/com/vaadin/server/AbstractClientConnector.java
+++ b/server/src/com/vaadin/server/AbstractClientConnector.java
@@ -290,6 +290,11 @@ public abstract class AbstractClientConnector implements ClientConnector {
@Override
public Object invoke(Object proxy, Method method, Object[] args)
throws Throwable {
+ if (method.getDeclaringClass() == Object.class) {
+ // Don't add Object methods such as toString and hashCode as
+ // invocations
+ return method.invoke(this, args);
+ }
addMethodInvocationToQueue(rpcInterfaceName, method, args);
return null;
}
diff --git a/server/src/com/vaadin/server/CommunicationManager.java b/server/src/com/vaadin/server/CommunicationManager.java
index f876e748f8..5f61079261 100644
--- a/server/src/com/vaadin/server/CommunicationManager.java
+++ b/server/src/com/vaadin/server/CommunicationManager.java
@@ -110,8 +110,9 @@ public class CommunicationManager extends AbstractCommunicationManager {
@Override
protected InputStream getThemeResourceAsStream(UI uI, String themeName,
String resource) {
- VaadinServletSession session = (VaadinServletSession) uI.getSession();
- ServletContext servletContext = session.getHttpSession()
+ VaadinServletService service = (VaadinServletService) uI.getSession()
+ .getService();
+ ServletContext servletContext = service.getServlet()
.getServletContext();
return servletContext.getResourceAsStream("/"
+ VaadinServlet.THEME_DIRECTORY_PATH + themeName + "/"
diff --git a/server/src/com/vaadin/server/DefaultUIProvider.java b/server/src/com/vaadin/server/DefaultUIProvider.java
index 1652d39c3a..e02e5dc860 100644
--- a/server/src/com/vaadin/server/DefaultUIProvider.java
+++ b/server/src/com/vaadin/server/DefaultUIProvider.java
@@ -24,9 +24,11 @@ public class DefaultUIProvider extends UIProvider {
public Class<? extends UI> getUIClass(UIClassSelectionEvent event) {
VaadinRequest request = event.getRequest();
- Object uiClassNameObj = request.getService()
- .getDeploymentConfiguration().getInitParameters()
- .getProperty(VaadinServiceSession.UI_PARAMETER);
+ Object uiClassNameObj = request
+ .getService()
+ .getDeploymentConfiguration()
+ .getApplicationOrSystemProperty(
+ VaadinServiceSession.UI_PARAMETER, null);
if (uiClassNameObj instanceof String) {
String uiClassName = uiClassNameObj.toString();
diff --git a/server/src/com/vaadin/server/GAEVaadinServlet.java b/server/src/com/vaadin/server/GAEVaadinServlet.java
index 6c9c1882ea..c68f25a282 100644
--- a/server/src/com/vaadin/server/GAEVaadinServlet.java
+++ b/server/src/com/vaadin/server/GAEVaadinServlet.java
@@ -361,11 +361,18 @@ public class GAEVaadinServlet extends VaadinServlet {
*
* @param request
*/
- private void cleanSession(HttpServletRequest request) {
- HttpSession session = request.getSession(false);
- if (session != null) {
- session.removeAttribute(VaadinServletSession.class.getName());
+ private void cleanSession(VaadinServletRequest request) {
+ // Should really be replaced with a session storage API...
+ WrappedSession wrappedSession = request.getWrappedSession(false);
+ if (wrappedSession == null) {
+ return;
+ }
+ VaadinServiceSession serviceSession = VaadinServiceSession
+ .getForSession(getService(), wrappedSession);
+ if (serviceSession == null) {
+ return;
}
+ serviceSession.removeFromSession(getService());
}
/**
diff --git a/server/src/com/vaadin/server/GlobalResourceHandler.java b/server/src/com/vaadin/server/GlobalResourceHandler.java
index c968dba066..ad276dc77a 100644
--- a/server/src/com/vaadin/server/GlobalResourceHandler.java
+++ b/server/src/com/vaadin/server/GlobalResourceHandler.java
@@ -59,7 +59,7 @@ public class GlobalResourceHandler implements RequestHandler {
private int nextLegacyId = 0;
// APP/global/[uiid]/[type]/[id]
- private final Matcher matcher = Pattern.compile(
+ private static final Matcher matcher = Pattern.compile(
"^/?" + ApplicationConstants.APP_REQUEST_PATH
+ RESOURCE_REQUEST_PATH + "(\\d+)/(([^/]+)(/.*))").matcher(
"");
diff --git a/server/src/com/vaadin/server/VaadinService.java b/server/src/com/vaadin/server/VaadinService.java
index add32bf57b..c56d6caeb5 100644
--- a/server/src/com/vaadin/server/VaadinService.java
+++ b/server/src/com/vaadin/server/VaadinService.java
@@ -437,8 +437,10 @@ public abstract class VaadinService implements Serializable {
* @throws ServletException
* @throws MalformedURLException
*/
- protected abstract VaadinServiceSession createVaadinSession(
- VaadinRequest request) throws ServiceException;
+ protected VaadinServiceSession createVaadinSession(VaadinRequest request)
+ throws ServiceException {
+ return new VaadinServiceSession(this);
+ }
private void onVaadinSessionStarted(VaadinRequest request,
VaadinServiceSession session) throws ServiceException {
diff --git a/server/src/com/vaadin/server/VaadinServlet.java b/server/src/com/vaadin/server/VaadinServlet.java
index 7f664be6fb..0620035274 100644
--- a/server/src/com/vaadin/server/VaadinServlet.java
+++ b/server/src/com/vaadin/server/VaadinServlet.java
@@ -232,7 +232,7 @@ public class VaadinServlet extends HttpServlet implements Constants {
return;
}
- VaadinServletSession vaadinSession = null;
+ VaadinServiceSession vaadinSession = null;
try {
// If a duplicate "close application" URL is received for an
@@ -254,8 +254,7 @@ public class VaadinServlet extends HttpServlet implements Constants {
}
// Find out the service session this request is related to
- vaadinSession = (VaadinServletSession) getService()
- .findVaadinSession(request);
+ vaadinSession = getService().findVaadinSession(request);
if (vaadinSession == null) {
return;
}
@@ -289,6 +288,11 @@ public class VaadinServlet extends HttpServlet implements Constants {
// Handles AJAX UIDL requests
communicationManager.handleUidlRequest(request, response,
servletWrapper, uI);
+
+ // Ensure that the browser does not cache UIDL responses.
+ // iOS 6 Safari requires this (#9732)
+ response.setHeader("Cache-Control", "no-cache");
+
return;
} else if (requestType == RequestType.BROWSER_DETAILS) {
// Browser details - not related to a specific UI
@@ -1173,26 +1177,6 @@ public class VaadinServlet extends HttpServlet implements Constants {
return request.getPathInfo();
}
- /**
- * Gets relative location of a theme resource.
- *
- * @param theme
- * the Theme name.
- * @param resource
- * the Theme resource.
- * @return External URI specifying the resource
- *
- * @deprecated might be refactored or removed before 7.0.0
- */
- @Deprecated
- public String getResourceLocation(String theme, ThemeResource resource) {
-
- if (resourcePath == null) {
- return resource.getResourceId();
- }
- return resourcePath + theme + "/" + resource.getResourceId();
- }
-
public class RequestError implements Terminal.ErrorEvent, Serializable {
private final Throwable throwable;
diff --git a/server/src/com/vaadin/server/VaadinServletService.java b/server/src/com/vaadin/server/VaadinServletService.java
index ca894b8a4f..d746ee2303 100644
--- a/server/src/com/vaadin/server/VaadinServletService.java
+++ b/server/src/com/vaadin/server/VaadinServletService.java
@@ -186,12 +186,6 @@ public class VaadinServletService extends VaadinService {
}
@Override
- protected VaadinServiceSession createVaadinSession(VaadinRequest request)
- throws ServiceException {
- return new VaadinServletSession(this);
- }
-
- @Override
public String getServiceName() {
return getServlet().getServletName();
}
diff --git a/server/src/com/vaadin/server/VaadinServletSession.java b/server/src/com/vaadin/server/VaadinServletSession.java
deleted file mode 100644
index aa31a19c1b..0000000000
--- a/server/src/com/vaadin/server/VaadinServletSession.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright 2011 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.server;
-
-import javax.servlet.http.HttpSession;
-import javax.servlet.http.HttpSessionBindingListener;
-
-/**
- * Web application context for Vaadin applications.
- *
- * This is automatically added as a {@link HttpSessionBindingListener} when
- * added to a {@link HttpSession}.
- *
- * @author Vaadin Ltd.
- * @since 3.1
- *
- * @deprecated might be refactored or removed before 7.0.0
- */
-@Deprecated
-@SuppressWarnings("serial")
-public class VaadinServletSession extends VaadinServiceSession {
-
- /**
- * Create a servlet service session for the given servlet service
- *
- * @param service
- * the servlet service to which the new session belongs
- */
- public VaadinServletSession(VaadinServletService service) {
- super(service);
- }
-
- /**
- * Gets the http-session application is running in.
- *
- * @return HttpSession this application context resides in.
- */
- public HttpSession getHttpSession() {
- WrappedSession session = getSession();
- return ((WrappedHttpSession) session).getHttpSession();
- }
-
-}
diff --git a/server/src/com/vaadin/server/WrappedHttpSession.java b/server/src/com/vaadin/server/WrappedHttpSession.java
index e13a63635b..65db010ba9 100644
--- a/server/src/com/vaadin/server/WrappedHttpSession.java
+++ b/server/src/com/vaadin/server/WrappedHttpSession.java
@@ -88,4 +88,9 @@ public class WrappedHttpSession implements WrappedSession {
session.invalidate();
}
+ @Override
+ public String getId() {
+ return session.getId();
+ }
+
}
diff --git a/server/src/com/vaadin/server/WrappedPortletSession.java b/server/src/com/vaadin/server/WrappedPortletSession.java
index 03c1d7ba1f..f4a6003ed5 100644
--- a/server/src/com/vaadin/server/WrappedPortletSession.java
+++ b/server/src/com/vaadin/server/WrappedPortletSession.java
@@ -74,4 +74,9 @@ public class WrappedPortletSession implements WrappedSession {
public void invalidate() {
session.invalidate();
}
+
+ @Override
+ public String getId() {
+ return session.getId();
+ }
}
diff --git a/server/src/com/vaadin/server/WrappedSession.java b/server/src/com/vaadin/server/WrappedSession.java
index 34443239c7..cf0b1a2fbd 100644
--- a/server/src/com/vaadin/server/WrappedSession.java
+++ b/server/src/com/vaadin/server/WrappedSession.java
@@ -86,4 +86,11 @@ public interface WrappedSession {
* @see PortletSession#invalidate()
*/
public void invalidate();
+
+ /**
+ * Gets a string with a unique identifier for the session.
+ *
+ * @return a unique session id string
+ */
+ public String getId();
}
diff --git a/server/src/com/vaadin/ui/Button.java b/server/src/com/vaadin/ui/Button.java
index 02b7689259..d248efd570 100644
--- a/server/src/com/vaadin/ui/Button.java
+++ b/server/src/com/vaadin/ui/Button.java
@@ -463,7 +463,6 @@ public class Button extends AbstractComponent implements
*
*/
public static class ClickShortcut extends ShortcutListener {
- protected Button button;
/**
* Creates a keyboard shortcut for clicking the given button using the
@@ -476,7 +475,8 @@ public class Button extends AbstractComponent implements
*/
public ClickShortcut(Button button, String shorthandCaption) {
super(shorthandCaption);
- this.button = button;
+ setTarget(button);
+ setTargetAction("click");
}
/**
@@ -492,7 +492,8 @@ public class Button extends AbstractComponent implements
*/
public ClickShortcut(Button button, int keyCode, int... modifiers) {
super(null, keyCode, modifiers);
- this.button = button;
+ setTarget(button);
+ setTargetAction("click");
}
/**
@@ -510,7 +511,7 @@ public class Button extends AbstractComponent implements
@Override
public void handleAction(Object sender, Object target) {
- button.click();
+ // Action handled on the client side
}
}
diff --git a/server/src/com/vaadin/ui/Label.java b/server/src/com/vaadin/ui/Label.java
index 9434e92186..89281e0c27 100644
--- a/server/src/com/vaadin/ui/Label.java
+++ b/server/src/com/vaadin/ui/Label.java
@@ -219,7 +219,7 @@ public class Label extends AbstractComponent implements Property<String>,
public String toString() {
logger.warning("You are using Label.toString() to get the value for a "
+ getClass().getSimpleName()
- + ". This is not recommended and will not be supported in future versions.");
+ + ". This will not be supported starting from Vaadin 7.1 (your debugger might call toString() and cause this message to appear).");
return getValue();
}