From a003c8724c1f719e3a9f3ab876396a180b19cae1 Mon Sep 17 00:00:00 2001 From: John Alhroos Date: Tue, 18 Sep 2012 10:11:02 +0000 Subject: Merged shortcut action fix from 6.8 (#8484) Change-Id: I1bc200afa9f4a4f3c5e469eb0b2f93278cca97a7 --- server/src/com/vaadin/event/ActionManager.java | 30 ++++++++++++++--- server/src/com/vaadin/event/ShortcutAction.java | 45 +++++++++++++++++++++++++ server/src/com/vaadin/ui/Button.java | 9 ++--- 3 files changed, 75 insertions(+), 9 deletions(-) (limited to 'server') diff --git a/server/src/com/vaadin/event/ActionManager.java b/server/src/com/vaadin/event/ActionManager.java index 85a1bf0f12..ad643863a7 100644 --- a/server/src/com/vaadin/event/ActionManager.java +++ b/server/src/com/vaadin/event/ActionManager.java @@ -18,6 +18,7 @@ package com.vaadin.event; import java.util.HashSet; import java.util.Map; +import com.vaadin.client.ui.ShortcutActionHandler; import com.vaadin.event.Action.Container; import com.vaadin.event.Action.Handler; import com.vaadin.server.KeyMapper; @@ -187,14 +188,29 @@ public class ActionManager implements Action.Container, Action.Handler, } if (a instanceof ShortcutAction) { final ShortcutAction sa = (ShortcutAction) a; - paintTarget.addAttribute("kc", sa.getKeyCode()); + paintTarget + .addAttribute( + ShortcutActionHandler.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( + ShortcutActionHandler.ACTION_MODIFIER_KEYS_ATTRIBUTE, + smodifiers); + } + if (sa.getTarget() != null) { + paintTarget.addAttribute( + ShortcutActionHandler.ACTION_TARGET_ATTRIBUTE, + sa.getTarget()); + paintTarget + .addAttribute( + ShortcutActionHandler.ACTION_TARGET_ACTION_ATTRIBUTE, + sa.getTargetAction()); } } paintTarget.endTag("action"); @@ -212,10 +228,14 @@ public class ActionManager implements Action.Container, Action.Handler, } public void handleActions(Map variables, Container sender) { - if (variables.containsKey("action") && actionMapper != null) { - final String key = (String) variables.get("action"); + if (variables + .containsKey(ShortcutActionHandler.ACTION_TARGET_ACTION_VARIABLE) + && actionMapper != null) { + final String key = (String) variables + .get(ShortcutActionHandler.ACTION_TARGET_ACTION_VARIABLE); final Action action = actionMapper.get(key); - final Object target = variables.get("actiontarget"); + final Object target = variables + .get(ShortcutActionHandler.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.
@@ -236,6 +241,46 @@ public class ShortcutAction extends Action { return modifiers; } + /** + * 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/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 } } -- cgit v1.2.3 From c057cf73a79e670a4d5458b03fe49c35ecd54675 Mon Sep 17 00:00:00 2001 From: Leif Åstrand Date: Fri, 28 Sep 2012 15:31:03 +0300 Subject: Remove VaadinServletSession (#9638) Change-Id: I0e25ba1a6d258b8601c009f6dc062b3f4bd3dbce --- .../com/vaadin/server/CommunicationManager.java | 5 +- server/src/com/vaadin/server/GAEVaadinServlet.java | 15 ++++-- server/src/com/vaadin/server/VaadinService.java | 6 ++- server/src/com/vaadin/server/VaadinServlet.java | 5 +- .../com/vaadin/server/VaadinServletService.java | 6 --- .../com/vaadin/server/VaadinServletSession.java | 57 ---------------------- .../src/com/vaadin/server/WrappedHttpSession.java | 5 ++ .../com/vaadin/server/WrappedPortletSession.java | 5 ++ server/src/com/vaadin/server/WrappedSession.java | 7 +++ .../tests/applicationcontext/ChangeSessionId.java | 15 +++--- 10 files changed, 43 insertions(+), 83 deletions(-) delete mode 100644 server/src/com/vaadin/server/VaadinServletSession.java (limited to 'server') 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/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/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..e73be682c2 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; } 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 @@ -185,12 +185,6 @@ public class VaadinServletService extends VaadinService { return (VaadinServletResponse) VaadinService.getCurrentResponse(); } - @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/uitest/src/com/vaadin/tests/applicationcontext/ChangeSessionId.java b/uitest/src/com/vaadin/tests/applicationcontext/ChangeSessionId.java index 4495b343d0..fa0f13e172 100644 --- a/uitest/src/com/vaadin/tests/applicationcontext/ChangeSessionId.java +++ b/uitest/src/com/vaadin/tests/applicationcontext/ChangeSessionId.java @@ -1,7 +1,6 @@ package com.vaadin.tests.applicationcontext; import com.vaadin.server.VaadinService; -import com.vaadin.server.VaadinServletSession; import com.vaadin.tests.components.AbstractTestCase; import com.vaadin.tests.util.Log; import com.vaadin.ui.Button; @@ -30,15 +29,13 @@ public class ChangeSessionId extends AbstractTestCase { })); setMainWindow(mainWindow); - loginButton.addListener(new ClickListener() { + loginButton.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { - VaadinServletSession context = ((VaadinServletSession) getContext()); - - String oldSessionId = context.getHttpSession().getId(); - context.getService().reinitializeSession( - VaadinService.getCurrentRequest()); - String newSessionId = context.getHttpSession().getId(); + String oldSessionId = getSessionId(); + VaadinService.reinitializeSession(VaadinService + .getCurrentRequest()); + String newSessionId = getSessionId(); if (oldSessionId.equals(newSessionId)) { log.log("FAILED! Both old and new session id is " + newSessionId); @@ -57,7 +54,7 @@ public class ChangeSessionId extends AbstractTestCase { } protected String getSessionId() { - return ((VaadinServletSession) getContext()).getHttpSession().getId(); + return getContext().getSession().getId(); } @Override -- cgit v1.2.3 From 72ea54d8fa00ea17f462541584d51098929da895 Mon Sep 17 00:00:00 2001 From: Leif Åstrand Date: Mon, 1 Oct 2012 11:59:53 +0300 Subject: Remove unused method (#9634) Change-Id: Iad6f920d345832ec6bec49761a31ceb7290679e9 --- server/src/com/vaadin/server/VaadinServlet.java | 20 -------------------- 1 file changed, 20 deletions(-) (limited to 'server') diff --git a/server/src/com/vaadin/server/VaadinServlet.java b/server/src/com/vaadin/server/VaadinServlet.java index e73be682c2..9d1d79d8b1 100644 --- a/server/src/com/vaadin/server/VaadinServlet.java +++ b/server/src/com/vaadin/server/VaadinServlet.java @@ -1172,26 +1172,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; -- cgit v1.2.3 From d371ac4a4e3f7f29f5a17f16c4134062c280115e Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Fri, 28 Sep 2012 20:47:34 +0300 Subject: Avoid adding RpcInvocationHandler toString as invocations (#9802) Change-Id: If6f378c0942132110adc748bd2c1cf87779924b6 --- .../com/vaadin/server/AbstractClientConnector.java | 5 ++ .../ui/RpcInvocationHandlerToString.html | 51 +++++++++++++++ .../ui/RpcInvocationHandlerToString.java | 74 ++++++++++++++++++++++ 3 files changed, 130 insertions(+) create mode 100644 uitest/src/com/vaadin/tests/components/ui/RpcInvocationHandlerToString.html create mode 100644 uitest/src/com/vaadin/tests/components/ui/RpcInvocationHandlerToString.java (limited to 'server') 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/uitest/src/com/vaadin/tests/components/ui/RpcInvocationHandlerToString.html b/uitest/src/com/vaadin/tests/components/ui/RpcInvocationHandlerToString.html new file mode 100644 index 0000000000..c9d5aa303d --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/ui/RpcInvocationHandlerToString.html @@ -0,0 +1,51 @@ + + + + + + +New Test + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
New Test
open/run/com.vaadin.tests.components.ui.RpcInvocationHandlerToString?restartApplication
clickvaadin=runcomvaadintestscomponentsuiRpcInvocationHandlerToString::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VButton[0]/domChild[0]/domChild[0]
assertElementNotPresentvaadin=runcomvaadintestscomponentsuiRpcInvocationHandlerToString::Root/VNotification[0]/HTML[0]
clickvaadin=runcomvaadintestscomponentsuiRpcInvocationHandlerToString::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[2]/VButton[0]/domChild[0]/domChild[0]
assertElementNotPresentvaadin=runcomvaadintestscomponentsuiRpcInvocationHandlerToString::Root/VNotification[0]/HTML[0]
clickvaadin=runcomvaadintestscomponentsuiRpcInvocationHandlerToString::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[3]/VButton[0]/domChild[0]/domChild[0]
assertElementNotPresentvaadin=runcomvaadintestscomponentsuiRpcInvocationHandlerToString::Root/VNotification[0]/HTML[0]
+ + diff --git a/uitest/src/com/vaadin/tests/components/ui/RpcInvocationHandlerToString.java b/uitest/src/com/vaadin/tests/components/ui/RpcInvocationHandlerToString.java new file mode 100644 index 0000000000..38f971f840 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/ui/RpcInvocationHandlerToString.java @@ -0,0 +1,74 @@ +/* + * 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.tests.components.ui; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.shared.ui.ui.PageClientRpc; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.tests.util.Log; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; + +public class RpcInvocationHandlerToString extends AbstractTestUI { + + private Log log = new Log(5); + PageClientRpc dummyProxy = getRpcProxy(PageClientRpc.class); + + @Override + protected void setup(VaadinRequest request) { + addComponent(log); + Button b = new Button("Exec toString() for an invocation proxy", + new Button.ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + log.log("An invoation proxy: " + dummyProxy.toString()); + } + }); + addComponent(b); + b = new Button("Exec hashCode() for an invocation proxy", + new Button.ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + log.log("Invocation proxy.hashCode(): " + + dummyProxy.hashCode()); + } + }); + addComponent(b); + b = new Button("Exec equals(false) for an invocation proxy", + new Button.ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + log.log("Invocation proxy.equals(false): " + + dummyProxy.equals(false)); + } + }); + addComponent(b); + } + + @Override + protected String getTestDescription() { + return "Clicking on the buttons invokes Object methods on a dummy proxy instance. They should only cause log rows to appear and no client rpc to be sent"; + } + + @Override + protected Integer getTicketNumber() { + return 9802; + } + +} -- cgit v1.2.3 From 0e3b55601457da2d5bc9edb85d2de701409aeb5c Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Mon, 1 Oct 2012 14:08:33 +0300 Subject: Avoid throwing exceptions from toString, log message instead (#9804) Change-Id: Ia2f8504a0fe75ab3a7c4746d533e5fd012e2a69c --- server/src/com/vaadin/data/util/AbstractProperty.java | 18 +++++++++++++++--- server/src/com/vaadin/data/util/IndexedContainer.java | 18 ++++++++++++++++-- .../vaadin/data/util/sqlcontainer/ColumnProperty.java | 18 ++++++++++++++++-- 3 files changed, 47 insertions(+), 7 deletions(-) (limited to 'server') 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 implements Property, @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 implements Property, 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) { -- cgit v1.2.3 From 6da74b9512c50ffe736160d697913552c70172ef Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Mon, 1 Oct 2012 18:53:43 +0300 Subject: Moved ShortcutActionHandler constants to shared (#8484) Change-Id: Ia75fa0ca8b7f563ccc412381e88abae7c630569e --- .../vaadin/client/ui/ShortcutActionHandler.java | 32 ++++++++++------------ server/src/com/vaadin/event/ActionManager.java | 21 +++++++------- 2 files changed, 24 insertions(+), 29 deletions(-) (limited to 'server') diff --git a/client/src/com/vaadin/client/ui/ShortcutActionHandler.java b/client/src/com/vaadin/client/ui/ShortcutActionHandler.java index 929de7a15d..cd14f14585 100644 --- a/client/src/com/vaadin/client/ui/ShortcutActionHandler.java +++ b/client/src/com/vaadin/client/ui/ShortcutActionHandler.java @@ -35,6 +35,7 @@ import com.vaadin.client.UIDL; import com.vaadin.client.Util; import com.vaadin.client.ui.richtextarea.VRichTextArea; import com.vaadin.shared.Connector; +import com.vaadin.shared.ui.ShortCutConstants; /** * A helper class to implement keyboard shorcut handling. Keeps a list of owners @@ -45,15 +46,6 @@ import com.vaadin.shared.Connector; */ public class ShortcutActionHandler { - public static final String ACTION_TARGET_ATTRIBUTE = "sat"; - public static final String ACTION_TARGET_ACTION_ATTRIBUTE = "sata"; - public static final String ACTION_CAPTION_ATTRIBUTE = "caption"; - public static final String ACTION_KEY_ATTRIBUTE = "key"; - public static final String ACTION_SHORTCUT_KEY_ATTRIBUTE = "kc"; - public static final String ACTION_MODIFIER_KEYS_ATTRIBUTE = "mk"; - public static final String ACTION_TARGET_VARIABLE = "actiontarget"; - public static final String ACTION_TARGET_ACTION_VARIABLE = "action"; - /** * An interface implemented by those users of this helper class that want to * support special components like {@link VRichTextArea} that don't properly @@ -119,21 +111,23 @@ public class ShortcutActionHandler { final UIDL action = (UIDL) it.next(); int[] modifiers = null; - if (action.hasAttribute(ACTION_MODIFIER_KEYS_ATTRIBUTE)) { + if (action + .hasAttribute(ShortCutConstants.ACTION_MODIFIER_KEYS_ATTRIBUTE)) { modifiers = action - .getIntArrayAttribute(ACTION_MODIFIER_KEYS_ATTRIBUTE); + .getIntArrayAttribute(ShortCutConstants.ACTION_MODIFIER_KEYS_ATTRIBUTE); } final ShortcutKeyCombination kc = new ShortcutKeyCombination( - action.getIntAttribute(ACTION_SHORTCUT_KEY_ATTRIBUTE), + action.getIntAttribute(ShortCutConstants.ACTION_SHORTCUT_KEY_ATTRIBUTE), modifiers); - final String key = action.getStringAttribute(ACTION_KEY_ATTRIBUTE); + final String key = action + .getStringAttribute(ShortCutConstants.ACTION_KEY_ATTRIBUTE); final String caption = action - .getStringAttribute(ACTION_CAPTION_ATTRIBUTE); + .getStringAttribute(ShortCutConstants.ACTION_CAPTION_ATTRIBUTE); final String targetPID = action - .getStringAttribute(ACTION_TARGET_ATTRIBUTE); + .getStringAttribute(ShortCutConstants.ACTION_TARGET_ATTRIBUTE); final String targetAction = action - .getStringAttribute(ACTION_TARGET_ACTION_ATTRIBUTE); + .getStringAttribute(ShortCutConstants.ACTION_TARGET_ACTION_ATTRIBUTE); actions.add(new ShortcutAction(key, kc, caption, targetPID, targetAction)); } @@ -201,10 +195,12 @@ public class ShortcutActionHandler { if (!handledClientSide) { if (finalTarget != null) { client.updateVariable(paintableId, - ACTION_TARGET_VARIABLE, finalTarget, false); + ShortCutConstants.ACTION_TARGET_VARIABLE, + finalTarget, false); } client.updateVariable(paintableId, - ACTION_TARGET_ACTION_VARIABLE, a.getKey(), true); + ShortCutConstants.ACTION_TARGET_ACTION_VARIABLE, + a.getKey(), true); } } }); diff --git a/server/src/com/vaadin/event/ActionManager.java b/server/src/com/vaadin/event/ActionManager.java index ad643863a7..50bb2f8dad 100644 --- a/server/src/com/vaadin/event/ActionManager.java +++ b/server/src/com/vaadin/event/ActionManager.java @@ -18,13 +18,13 @@ package com.vaadin.event; import java.util.HashSet; import java.util.Map; -import com.vaadin.client.ui.ShortcutActionHandler; import com.vaadin.event.Action.Container; import com.vaadin.event.Action.Handler; 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; /** @@ -188,10 +188,9 @@ public class ActionManager implements Action.Container, Action.Handler, } if (a instanceof ShortcutAction) { final ShortcutAction sa = (ShortcutAction) a; - paintTarget - .addAttribute( - ShortcutActionHandler.ACTION_SHORTCUT_KEY_ATTRIBUTE, - 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]; @@ -200,16 +199,16 @@ public class ActionManager implements Action.Container, Action.Handler, } paintTarget .addAttribute( - ShortcutActionHandler.ACTION_MODIFIER_KEYS_ATTRIBUTE, + ShortCutConstants.ACTION_MODIFIER_KEYS_ATTRIBUTE, smodifiers); } if (sa.getTarget() != null) { paintTarget.addAttribute( - ShortcutActionHandler.ACTION_TARGET_ATTRIBUTE, + ShortCutConstants.ACTION_TARGET_ATTRIBUTE, sa.getTarget()); paintTarget .addAttribute( - ShortcutActionHandler.ACTION_TARGET_ACTION_ATTRIBUTE, + ShortCutConstants.ACTION_TARGET_ACTION_ATTRIBUTE, sa.getTargetAction()); } } @@ -229,13 +228,13 @@ public class ActionManager implements Action.Container, Action.Handler, public void handleActions(Map variables, Container sender) { if (variables - .containsKey(ShortcutActionHandler.ACTION_TARGET_ACTION_VARIABLE) + .containsKey(ShortCutConstants.ACTION_TARGET_ACTION_VARIABLE) && actionMapper != null) { final String key = (String) variables - .get(ShortcutActionHandler.ACTION_TARGET_ACTION_VARIABLE); + .get(ShortCutConstants.ACTION_TARGET_ACTION_VARIABLE); final Action action = actionMapper.get(key); final Object target = variables - .get(ShortcutActionHandler.ACTION_TARGET_VARIABLE); + .get(ShortCutConstants.ACTION_TARGET_VARIABLE); if (action != null) { handleAction(action, sender, target); } -- cgit v1.2.3 From def50dcdd7f28f9f4f92fb723191049f67fd21e4 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Mon, 1 Oct 2012 23:37:05 +0300 Subject: Made GlobalResourceHandler serializable (#9817) Change-Id: Iae2ac641275a7f16b0bde2184c3f42f9f059f890 --- server/src/com/vaadin/server/GlobalResourceHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'server') 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( ""); -- cgit v1.2.3 From 2ad19298bd12237dfaf3b2bc9ee9f7aafe737ecb Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Mon, 1 Oct 2012 23:40:29 +0300 Subject: Unified log message with other Property implementors (#9804) Change-Id: I0833381d7f7871d062b04ef0ed5408f1777022af --- server/src/com/vaadin/ui/Label.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'server') 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, 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(); } -- cgit v1.2.3 From 25b4d23647b1056097c2a4b2761bfe25d8928b7a Mon Sep 17 00:00:00 2001 From: Leif Åstrand Date: Tue, 2 Oct 2012 10:21:39 +0300 Subject: Make DefaultUIProvider work with lower case parameter name (#9474) Change-Id: I1c66f1661fee32ce924f5923c15a5c86b25465e1 --- server/src/com/vaadin/server/DefaultUIProvider.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'server') 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 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(); -- cgit v1.2.3 From a930bbb16eeb7c8663c136b441ff44024c615447 Mon Sep 17 00:00:00 2001 From: Johannes Dahlström Date: Tue, 25 Sep 2012 11:25:04 +0000 Subject: Ensure the browser does not cache UIDL responses (#9732) svn changeset:24575/svn branch:6.8 Conflicts: src/com/vaadin/terminal/gwt/server/CommunicationManager.java Change-Id: I64a1a8300ab1d96e7a9b22c5ed53398cf0dd3f74 --- server/src/com/vaadin/server/VaadinServlet.java | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'server') diff --git a/server/src/com/vaadin/server/VaadinServlet.java b/server/src/com/vaadin/server/VaadinServlet.java index 9d1d79d8b1..0620035274 100644 --- a/server/src/com/vaadin/server/VaadinServlet.java +++ b/server/src/com/vaadin/server/VaadinServlet.java @@ -288,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 -- cgit v1.2.3