summaryrefslogtreecommitdiffstats
path: root/server/src/com/vaadin
diff options
context:
space:
mode:
authorLeif Åstrand <leif@vaadin.com>2013-06-12 09:14:10 +0300
committerLeif Åstrand <leif@vaadin.com>2013-06-12 09:14:11 +0300
commitbe274254b5e6f4dd9386d4a3dd994ec834147e8b (patch)
treee6fcf610b76814916ed333b4e12b0ef384316084 /server/src/com/vaadin
parent38cfb0d8eaaa9c146a394558260d2a7e36b6e414 (diff)
parentecc2de3ff1b9998c8a7ca496e71a13c53acd5c84 (diff)
downloadvaadin-framework-be274254b5e6f4dd9386d4a3dd994ec834147e8b.tar.gz
vaadin-framework-be274254b5e6f4dd9386d4a3dd994ec834147e8b.zip
Merge changes from origin/7.1
9100cfc Do not rely on broken javadoc features for default values (#11970) fad7bf7 Remove DEFAULT constant as an annotation enum cannot use it (#11966) 1f14422 Merge changes from origin/7.0 9b38072 Exclude provided portal-service from all zip (#9823) 8f4add9 Fixed button highlighting when dragging #10917 8eb567e Make UI.pushConnection transient to prevent null resource after deserialization (#11809) 9efd4d6 Fixed test issues 1b0a214 Pass ConversionException to getConversionError (#11960) bca14c0 Correctly report theme version in the debug window (#11442) f9bffed Fix for NPE in debug window in IE (#12015) da29e2b Fixed serialization issues a5ec937 Info section for the debug window (#12019) d6fca78 Fix race condition in upload with push (#10214) e7201fd Allow using element resize listeners from javascript connectors (#11996) e853280 Print warning if in production mode and theme compilation is required (#12031) d9becf9 Use vaadin-atmosphere without slf4j dependency (#11765) 37bc9e4 Reformatted using Ant editor (#12040) 5adb5c2 Include compatibility web.xml in uitest.war (#11688) 424af57 Move ClientConnector.setParent to Component and Extension (#11777) 074d7b3 Fixed incorrect line breaks (#12040) 2cada0b Reformatted release notes using Eclipse (4 spaces) a0182a0 Updated release notes for 7.1.0 (#11993, #11991, #11870) 5793a1c Make VaadinServlet use enclosing UI class by default (#12039) 3d9d47d Added type parameter to converter methods (#11895) ecc2de3 Removed dead code Change-Id: I68ad269dc46ac03d7285b92e0ebdcd3eda059629
Diffstat (limited to 'server/src/com/vaadin')
-rw-r--r--server/src/com/vaadin/annotations/Push.java2
-rw-r--r--server/src/com/vaadin/annotations/VaadinServletConfiguration.java11
-rw-r--r--server/src/com/vaadin/data/util/converter/AbstractStringToNumberConverter.java6
-rw-r--r--server/src/com/vaadin/data/util/converter/Converter.java37
-rw-r--r--server/src/com/vaadin/data/util/converter/ConverterUtil.java24
-rw-r--r--server/src/com/vaadin/data/util/converter/DateToLongConverter.java15
-rw-r--r--server/src/com/vaadin/data/util/converter/DateToSqlDateConverter.java17
-rw-r--r--server/src/com/vaadin/data/util/converter/ReverseConverter.java10
-rw-r--r--server/src/com/vaadin/data/util/converter/StringToBooleanConverter.java10
-rw-r--r--server/src/com/vaadin/data/util/converter/StringToDateConverter.java21
-rw-r--r--server/src/com/vaadin/data/util/converter/StringToDoubleConverter.java5
-rw-r--r--server/src/com/vaadin/data/util/converter/StringToFloatConverter.java5
-rw-r--r--server/src/com/vaadin/data/util/converter/StringToIntegerConverter.java11
-rw-r--r--server/src/com/vaadin/data/util/converter/StringToNumberConverter.java13
-rw-r--r--server/src/com/vaadin/event/ActionManager.java13
-rw-r--r--server/src/com/vaadin/server/AbstractClientConnector.java34
-rw-r--r--server/src/com/vaadin/server/AbstractExtension.java33
-rw-r--r--server/src/com/vaadin/server/ClientConnector.java33
-rw-r--r--server/src/com/vaadin/server/Constants.java2
-rw-r--r--server/src/com/vaadin/server/DragAndDropService.java25
-rw-r--r--server/src/com/vaadin/server/Extension.java21
-rw-r--r--server/src/com/vaadin/server/LocaleService.java3
-rw-r--r--server/src/com/vaadin/server/Page.java2
-rw-r--r--server/src/com/vaadin/server/VaadinServlet.java29
-rw-r--r--server/src/com/vaadin/server/communication/AtmospherePushConnection.java26
-rw-r--r--server/src/com/vaadin/server/communication/PushConnection.java12
-rw-r--r--server/src/com/vaadin/server/communication/PushHandler.java23
-rw-r--r--server/src/com/vaadin/server/communication/UidlRequestHandler.java2
-rw-r--r--server/src/com/vaadin/ui/AbstractComponent.java34
-rw-r--r--server/src/com/vaadin/ui/AbstractField.java65
-rw-r--r--server/src/com/vaadin/ui/AbstractJavaScriptComponent.java10
-rw-r--r--server/src/com/vaadin/ui/Component.java26
-rw-r--r--server/src/com/vaadin/ui/Table.java3
-rw-r--r--server/src/com/vaadin/ui/UI.java24
-rw-r--r--server/src/com/vaadin/ui/Window.java3
35 files changed, 385 insertions, 225 deletions
diff --git a/server/src/com/vaadin/annotations/Push.java b/server/src/com/vaadin/annotations/Push.java
index d5e42d6f60..9965d535ba 100644
--- a/server/src/com/vaadin/annotations/Push.java
+++ b/server/src/com/vaadin/annotations/Push.java
@@ -54,6 +54,6 @@ public @interface Push {
*
* @return the transport type to use
*/
- public Transport transport() default Transport.DEFAULT;
+ public Transport transport() default Transport.WEBSOCKET;
}
diff --git a/server/src/com/vaadin/annotations/VaadinServletConfiguration.java b/server/src/com/vaadin/annotations/VaadinServletConfiguration.java
index 38e3ff2ef0..e65869c27a 100644
--- a/server/src/com/vaadin/annotations/VaadinServletConfiguration.java
+++ b/server/src/com/vaadin/annotations/VaadinServletConfiguration.java
@@ -84,8 +84,7 @@ public @interface VaadinServletConfiguration {
/**
* The time resources can be cached in the browser, in seconds. The default
- * value is
- * {@value DefaultDeploymentConfiguration#DEFAULT_RESOURCE_CACHE_TIME}.
+ * value is 3600 seconds, i.e. one hour.
*
* @return the resource cache time
*
@@ -96,8 +95,8 @@ public @interface VaadinServletConfiguration {
/**
* The number of seconds between heartbeat requests of a UI, or a
- * non-positive number if heartbeat is disabled. The default value is
- * {@value DefaultDeploymentConfiguration#DEFAULT_HEARTBEAT_INTERVAL}.
+ * non-positive number if heartbeat is disabled. The default value is 300
+ * seconds, i.e. 5 minutes.
*
* @return the time between heartbeats
*
@@ -109,7 +108,7 @@ public @interface VaadinServletConfiguration {
/**
* Whether a session should be closed when all its open UIs have been idle
* for longer than its configured maximum inactivity time. The default value
- * is {@value DefaultDeploymentConfiguration#DEFAULT_CLOSE_IDLE_SESSIONS}.
+ * is <code>false</code>.
*
* @return true if UIs and sessions receiving only heartbeat requests are
* eventually closed; false if heartbeat requests extend UI and
@@ -122,7 +121,7 @@ public @interface VaadinServletConfiguration {
/**
* The default widgetset to use for the servlet. The default value is
- * {@value VaadinServlet#DEFAULT_WIDGETSET}.
+ * <code>com.vaadin.DefaultWidgetSet</code>.
*
* @return the default widgetset name
*/
diff --git a/server/src/com/vaadin/data/util/converter/AbstractStringToNumberConverter.java b/server/src/com/vaadin/data/util/converter/AbstractStringToNumberConverter.java
index 5999d850b4..237f01bb22 100644
--- a/server/src/com/vaadin/data/util/converter/AbstractStringToNumberConverter.java
+++ b/server/src/com/vaadin/data/util/converter/AbstractStringToNumberConverter.java
@@ -65,7 +65,8 @@ public abstract class AbstractStringToNumberConverter<T> implements
* If there was a problem converting the value
* @since 7.1
*/
- protected Number convertToNumber(String value, Locale locale)
+ protected Number convertToNumber(String value,
+ Class<? extends Number> targetType, Locale locale)
throws ConversionException {
if (value == null) {
return null;
@@ -98,7 +99,8 @@ public abstract class AbstractStringToNumberConverter<T> implements
* .Object, java.util.Locale)
*/
@Override
- public String convertToPresentation(T value, Locale locale)
+ public String convertToPresentation(T value,
+ Class<? extends String> targetType, Locale locale)
throws ConversionException {
if (value == null) {
return null;
diff --git a/server/src/com/vaadin/data/util/converter/Converter.java b/server/src/com/vaadin/data/util/converter/Converter.java
index ded7da7fb5..3c391af434 100644
--- a/server/src/com/vaadin/data/util/converter/Converter.java
+++ b/server/src/com/vaadin/data/util/converter/Converter.java
@@ -22,10 +22,10 @@ import java.util.Locale;
/**
* Interface that implements conversion between a model and a presentation type.
* <p>
- * Typically {@link #convertToPresentation(Object, Locale)} and
- * {@link #convertToModel(Object, Locale)} should be symmetric so that chaining
- * these together returns the original result for all input but this is not a
- * requirement.
+ * Typically {@link #convertToPresentation(Object, Class, Locale)} and
+ * {@link #convertToModel(Object, Class, Locale)} should be symmetric so that
+ * chaining these together returns the original result for all input but this is
+ * not a requirement.
* </p>
* <p>
* Converters must not have any side effects (never update UI from inside a
@@ -55,19 +55,23 @@ public interface Converter<PRESENTATION, MODEL> extends Serializable {
* A converter can optionally use locale to do the conversion.
* </p>
* A converter should in most cases be symmetric so chaining
- * {@link #convertToPresentation(Object, Locale)} and
- * {@link #convertToModel(Object, Locale)} should return the original value.
+ * {@link #convertToPresentation(Object, Class, Locale)} and
+ * {@link #convertToModel(Object, Class, Locale)} should return the original
+ * value.
*
* @param value
* The value to convert, compatible with the target type. Can be
* null
+ * @param targetType
+ * The requested type of the return value
* @param locale
* The locale to use for conversion. Can be null.
* @return The converted value compatible with the source type
* @throws ConversionException
* If the value could not be converted
*/
- public MODEL convertToModel(PRESENTATION value, Locale locale)
+ public MODEL convertToModel(PRESENTATION value,
+ Class<? extends MODEL> targetType, Locale locale)
throws ConversionException;
/**
@@ -76,26 +80,30 @@ public interface Converter<PRESENTATION, MODEL> extends Serializable {
* A converter can optionally use locale to do the conversion.
* </p>
* A converter should in most cases be symmetric so chaining
- * {@link #convertToPresentation(Object, Locale)} and
- * {@link #convertToModel(Object, Locale)} should return the original value.
+ * {@link #convertToPresentation(Object, Class, Locale)} and
+ * {@link #convertToModel(Object, Class, Locale)} should return the original
+ * value.
*
* @param value
* The value to convert, compatible with the target type. Can be
* null
+ * @param targetType
+ * The requested type of the return value
* @param locale
* The locale to use for conversion. Can be null.
* @return The converted value compatible with the source type
* @throws ConversionException
* If the value could not be converted
*/
- public PRESENTATION convertToPresentation(MODEL value, Locale locale)
+ public PRESENTATION convertToPresentation(MODEL value,
+ Class<? extends PRESENTATION> targetType, Locale locale)
throws ConversionException;
/**
* The source type of the converter.
*
* Values of this type can be passed to
- * {@link #convertToPresentation(Object, Locale)}.
+ * {@link #convertToPresentation(Object, Class, Locale)}.
*
* @return The source type
*/
@@ -105,7 +113,7 @@ public interface Converter<PRESENTATION, MODEL> extends Serializable {
* The target type of the converter.
*
* Values of this type can be passed to
- * {@link #convertToModel(Object, Locale)}.
+ * {@link #convertToModel(Object, Class, Locale)}.
*
* @return The target type
*/
@@ -113,8 +121,9 @@ public interface Converter<PRESENTATION, MODEL> extends Serializable {
/**
* An exception that signals that the value passed to
- * {@link Converter#convertToPresentation(Object, Locale)} or
- * {@link Converter#convertToModel(Object, Locale)} could not be converted.
+ * {@link Converter#convertToPresentation(Object, Class, Locale)} or
+ * {@link Converter#convertToModel(Object, Class, Locale)} could not be
+ * converted.
*
* @author Vaadin Ltd
* @since 7.0
diff --git a/server/src/com/vaadin/data/util/converter/ConverterUtil.java b/server/src/com/vaadin/data/util/converter/ConverterUtil.java
index 08d7363084..3c62a71b73 100644
--- a/server/src/com/vaadin/data/util/converter/ConverterUtil.java
+++ b/server/src/com/vaadin/data/util/converter/ConverterUtil.java
@@ -86,7 +86,17 @@ public class ConverterUtil implements Serializable {
Converter<PRESENTATIONTYPE, MODELTYPE> converter, Locale locale)
throws Converter.ConversionException {
if (converter != null) {
- return converter.convertToPresentation(modelValue, locale);
+ PRESENTATIONTYPE presentation = converter.convertToPresentation(
+ modelValue, presentationType, locale);
+ if (!presentationType.isInstance(presentation)) {
+ throw new Converter.ConversionException(
+ "Converter returned an object of type "
+ + presentation.getClass().getName()
+ + " when expecting "
+ + presentationType.getName());
+ }
+
+ return presentation;
}
if (modelValue == null) {
return null;
@@ -123,7 +133,17 @@ public class ConverterUtil implements Serializable {
* If there is a converter, always use it. It must convert or throw
* an exception.
*/
- return converter.convertToModel(presentationValue, locale);
+ MODELTYPE model = converter.convertToModel(presentationValue,
+ modelType, locale);
+ if (!modelType.isInstance(model)) {
+ throw new Converter.ConversionException(
+ "Converter returned an object of type "
+ + model.getClass().getName()
+ + " when expecting " + modelType.getName());
+ }
+
+ return model;
+
}
if (presentationValue == null) {
diff --git a/server/src/com/vaadin/data/util/converter/DateToLongConverter.java b/server/src/com/vaadin/data/util/converter/DateToLongConverter.java
index 82dccdcacc..6aedc74f6d 100644
--- a/server/src/com/vaadin/data/util/converter/DateToLongConverter.java
+++ b/server/src/com/vaadin/data/util/converter/DateToLongConverter.java
@@ -32,10 +32,11 @@ public class DateToLongConverter implements Converter<Date, Long> {
*
* @see
* com.vaadin.data.util.converter.Converter#convertToModel(java.lang.Object,
- * java.util.Locale)
+ * java.lang.Class, java.util.Locale)
*/
@Override
- public Long convertToModel(Date value, Locale locale) {
+ public Long convertToModel(Date value, Class<? extends Long> targetType,
+ Locale locale) {
if (value == null) {
return null;
}
@@ -48,10 +49,16 @@ public class DateToLongConverter implements Converter<Date, Long> {
*
* @see
* com.vaadin.data.util.converter.Converter#convertToPresentation(java.lang
- * .Object, java.util.Locale)
+ * .Object, java.lang.Class, java.util.Locale)
*/
@Override
- public Date convertToPresentation(Long value, Locale locale) {
+ public Date convertToPresentation(Long value,
+ Class<? extends Date> targetType, Locale locale) {
+ if (targetType != getPresentationType()) {
+ throw new ConversionException("Converter only supports "
+ + getPresentationType().getName() + " (targetType was "
+ + targetType.getName() + ")");
+ }
if (value == null) {
return null;
}
diff --git a/server/src/com/vaadin/data/util/converter/DateToSqlDateConverter.java b/server/src/com/vaadin/data/util/converter/DateToSqlDateConverter.java
index 97027cc05b..cddf2d8a42 100644
--- a/server/src/com/vaadin/data/util/converter/DateToSqlDateConverter.java
+++ b/server/src/com/vaadin/data/util/converter/DateToSqlDateConverter.java
@@ -35,14 +35,27 @@ import java.util.Locale;
public class DateToSqlDateConverter implements Converter<Date, java.sql.Date> {
@Override
- public java.sql.Date convertToModel(Date value, Locale locale)
+ public java.sql.Date convertToModel(Date value,
+ Class<? extends java.sql.Date> targetType, Locale locale)
throws ConversionException {
+ if (targetType != getModelType()) {
+ throw new ConversionException("Converter only supports "
+ + getModelType().getName() + " (targetType was "
+ + targetType.getName() + ")");
+ }
+
return new java.sql.Date(value.getTime());
}
@Override
- public Date convertToPresentation(java.sql.Date value, Locale locale)
+ public Date convertToPresentation(java.sql.Date value,
+ Class<? extends Date> targetType, Locale locale)
throws ConversionException {
+ if (targetType != getPresentationType()) {
+ throw new ConversionException("Converter only supports "
+ + getPresentationType().getName() + " (targetType was "
+ + targetType.getName() + ")");
+ }
return new Date(value.getTime());
}
diff --git a/server/src/com/vaadin/data/util/converter/ReverseConverter.java b/server/src/com/vaadin/data/util/converter/ReverseConverter.java
index 94f333b7f3..6fa07696db 100644
--- a/server/src/com/vaadin/data/util/converter/ReverseConverter.java
+++ b/server/src/com/vaadin/data/util/converter/ReverseConverter.java
@@ -53,9 +53,10 @@ public class ReverseConverter<PRESENTATION, MODEL> implements
* .lang.Object, java.util.Locale)
*/
@Override
- public MODEL convertToModel(PRESENTATION value, Locale locale)
+ public MODEL convertToModel(PRESENTATION value,
+ Class<? extends MODEL> targetType, Locale locale)
throws com.vaadin.data.util.converter.Converter.ConversionException {
- return realConverter.convertToPresentation(value, locale);
+ return realConverter.convertToPresentation(value, targetType, locale);
}
/*
@@ -66,9 +67,10 @@ public class ReverseConverter<PRESENTATION, MODEL> implements
* .Object, java.util.Locale)
*/
@Override
- public PRESENTATION convertToPresentation(MODEL value, Locale locale)
+ public PRESENTATION convertToPresentation(MODEL value,
+ Class<? extends PRESENTATION> targetType, Locale locale)
throws com.vaadin.data.util.converter.Converter.ConversionException {
- return realConverter.convertToModel(value, locale);
+ return realConverter.convertToModel(value, targetType, locale);
}
/*
diff --git a/server/src/com/vaadin/data/util/converter/StringToBooleanConverter.java b/server/src/com/vaadin/data/util/converter/StringToBooleanConverter.java
index 1702d3808f..6af0933731 100644
--- a/server/src/com/vaadin/data/util/converter/StringToBooleanConverter.java
+++ b/server/src/com/vaadin/data/util/converter/StringToBooleanConverter.java
@@ -35,10 +35,11 @@ public class StringToBooleanConverter implements Converter<String, Boolean> {
*
* @see
* com.vaadin.data.util.converter.Converter#convertToModel(java.lang.Object,
- * java.util.Locale)
+ * java.lang.Class, java.util.Locale)
*/
@Override
- public Boolean convertToModel(String value, Locale locale)
+ public Boolean convertToModel(String value,
+ Class<? extends Boolean> targetType, Locale locale)
throws ConversionException {
if (value == null || value.isEmpty()) {
return null;
@@ -80,10 +81,11 @@ public class StringToBooleanConverter implements Converter<String, Boolean> {
*
* @see
* com.vaadin.data.util.converter.Converter#convertToPresentation(java.lang
- * .Object, java.util.Locale)
+ * .Object, java.lang.Class, java.util.Locale)
*/
@Override
- public String convertToPresentation(Boolean value, Locale locale)
+ public String convertToPresentation(Boolean value,
+ Class<? extends String> targetType, Locale locale)
throws ConversionException {
if (value == null) {
return null;
diff --git a/server/src/com/vaadin/data/util/converter/StringToDateConverter.java b/server/src/com/vaadin/data/util/converter/StringToDateConverter.java
index 0dcf1d4795..e3917c6a52 100644
--- a/server/src/com/vaadin/data/util/converter/StringToDateConverter.java
+++ b/server/src/com/vaadin/data/util/converter/StringToDateConverter.java
@@ -37,8 +37,9 @@ import java.util.Locale;
public class StringToDateConverter implements Converter<String, Date> {
/**
- * Returns the format used by {@link #convertToPresentation(Date, Locale)}
- * and {@link #convertToModel(String, Locale)}.
+ * Returns the format used by
+ * {@link #convertToPresentation(Date, Class,Locale)} and
+ * {@link #convertToModel(String, Class, Locale)}.
*
* @param locale
* The locale to use
@@ -60,11 +61,18 @@ public class StringToDateConverter implements Converter<String, Date> {
*
* @see
* com.vaadin.data.util.converter.Converter#convertToModel(java.lang.Object,
- * java.util.Locale)
+ * java.lang.Class, java.util.Locale)
*/
@Override
- public Date convertToModel(String value, Locale locale)
+ public Date convertToModel(String value, Class<? extends Date> targetType,
+ Locale locale)
throws com.vaadin.data.util.converter.Converter.ConversionException {
+ if (targetType != getModelType()) {
+ throw new ConversionException("Converter only supports "
+ + getModelType().getName() + " (targetType was "
+ + targetType.getName() + ")");
+ }
+
if (value == null) {
return null;
}
@@ -87,10 +95,11 @@ public class StringToDateConverter implements Converter<String, Date> {
*
* @see
* com.vaadin.data.util.converter.Converter#convertToPresentation(java.lang
- * .Object, java.util.Locale)
+ * .Object, java.lang.Class, java.util.Locale)
*/
@Override
- public String convertToPresentation(Date value, Locale locale)
+ public String convertToPresentation(Date value,
+ Class<? extends String> targetType, Locale locale)
throws com.vaadin.data.util.converter.Converter.ConversionException {
if (value == null) {
return null;
diff --git a/server/src/com/vaadin/data/util/converter/StringToDoubleConverter.java b/server/src/com/vaadin/data/util/converter/StringToDoubleConverter.java
index 8bb82498b9..c593d256da 100644
--- a/server/src/com/vaadin/data/util/converter/StringToDoubleConverter.java
+++ b/server/src/com/vaadin/data/util/converter/StringToDoubleConverter.java
@@ -44,9 +44,10 @@ public class StringToDoubleConverter extends
* java.util.Locale)
*/
@Override
- public Double convertToModel(String value, Locale locale)
+ public Double convertToModel(String value,
+ Class<? extends Double> targetType, Locale locale)
throws ConversionException {
- Number n = convertToNumber(value, locale);
+ Number n = convertToNumber(value, targetType, locale);
return n == null ? null : n.doubleValue();
}
diff --git a/server/src/com/vaadin/data/util/converter/StringToFloatConverter.java b/server/src/com/vaadin/data/util/converter/StringToFloatConverter.java
index a207654358..6fcb83a770 100644
--- a/server/src/com/vaadin/data/util/converter/StringToFloatConverter.java
+++ b/server/src/com/vaadin/data/util/converter/StringToFloatConverter.java
@@ -44,9 +44,10 @@ public class StringToFloatConverter extends
* java.util.Locale)
*/
@Override
- public Float convertToModel(String value, Locale locale)
+ public Float convertToModel(String value,
+ Class<? extends Float> targetType, Locale locale)
throws ConversionException {
- Number n = convertToNumber(value, locale);
+ Number n = convertToNumber(value, targetType, locale);
return n == null ? null : n.floatValue();
}
diff --git a/server/src/com/vaadin/data/util/converter/StringToIntegerConverter.java b/server/src/com/vaadin/data/util/converter/StringToIntegerConverter.java
index 4f34cf1cd3..bc436112fe 100644
--- a/server/src/com/vaadin/data/util/converter/StringToIntegerConverter.java
+++ b/server/src/com/vaadin/data/util/converter/StringToIntegerConverter.java
@@ -35,8 +35,8 @@ public class StringToIntegerConverter extends
/**
* Returns the format used by
- * {@link #convertToPresentation(Integer, Locale)} and
- * {@link #convertToModel(String, Locale)}.
+ * {@link #convertToPresentation(Integer, Class, Locale)} and
+ * {@link #convertToModel(String, Class, Locale)}
*
* @param locale
* The locale to use
@@ -55,12 +55,13 @@ public class StringToIntegerConverter extends
*
* @see
* com.vaadin.data.util.converter.Converter#convertToModel(java.lang.Object,
- * java.util.Locale)
+ * java.lang.Class, java.util.Locale)
*/
@Override
- public Integer convertToModel(String value, Locale locale)
+ public Integer convertToModel(String value,
+ Class<? extends Integer> targetType, Locale locale)
throws ConversionException {
- Number n = convertToNumber(value, locale);
+ Number n = convertToNumber(value, targetType, locale);
return n == null ? null : n.intValue();
}
diff --git a/server/src/com/vaadin/data/util/converter/StringToNumberConverter.java b/server/src/com/vaadin/data/util/converter/StringToNumberConverter.java
index eae73e4cfa..22df42403f 100644
--- a/server/src/com/vaadin/data/util/converter/StringToNumberConverter.java
+++ b/server/src/com/vaadin/data/util/converter/StringToNumberConverter.java
@@ -37,12 +37,19 @@ public class StringToNumberConverter extends
*
* @see
* com.vaadin.data.util.converter.Converter#convertToModel(java.lang.Object,
- * java.util.Locale)
+ * java.lang.Class, java.util.Locale)
*/
@Override
- public Number convertToModel(String value, Locale locale)
+ public Number convertToModel(String value,
+ Class<? extends Number> targetType, Locale locale)
throws ConversionException {
- return convertToNumber(value, locale);
+ if (targetType != getModelType()) {
+ throw new ConversionException("Converter only supports "
+ + getModelType().getName() + " (targetType was "
+ + targetType.getName() + ")");
+ }
+
+ return convertToNumber(value, targetType, locale);
}
/*
diff --git a/server/src/com/vaadin/event/ActionManager.java b/server/src/com/vaadin/event/ActionManager.java
index ce3e27d539..8d7a64b364 100644
--- a/server/src/com/vaadin/event/ActionManager.java
+++ b/server/src/com/vaadin/event/ActionManager.java
@@ -15,6 +15,7 @@
*/
package com.vaadin.event;
+import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.Map;
@@ -43,11 +44,15 @@ public class ActionManager implements Action.Container, Action.Handler,
private static final long serialVersionUID = 1641868163608066491L;
- /** List of action handlers */
- protected LinkedHashSet<Action> ownActions = null;
+ /**
+ * List of action handlers. Guaranteed to keep the original insertion order.
+ */
+ protected HashSet<Action> ownActions = null;
- /** List of action handlers */
- protected LinkedHashSet<Handler> actionHandlers = null;
+ /**
+ * List of action handlers. Guaranteed to keep the original insertion order.
+ */
+ protected HashSet<Handler> actionHandlers = null;
/** Action mapper */
protected KeyMapper<Action> actionMapper = null;
diff --git a/server/src/com/vaadin/server/AbstractClientConnector.java b/server/src/com/vaadin/server/AbstractClientConnector.java
index 01f7d9af42..c3101924dd 100644
--- a/server/src/com/vaadin/server/AbstractClientConnector.java
+++ b/server/src/com/vaadin/server/AbstractClientConnector.java
@@ -84,8 +84,6 @@ public abstract class AbstractClientConnector implements ClientConnector,
private ArrayList<Extension> extensions = new ArrayList<Extension>();
- private ClientConnector parent;
-
/**
* The EventRouter used for the event model.
*/
@@ -563,38 +561,6 @@ public abstract class AbstractClientConnector implements ClientConnector,
markAsDirty();
}
- @Override
- public void setParent(ClientConnector parent) {
-
- // If the parent is not changed, don't do anything
- if (parent == this.parent) {
- return;
- }
-
- if (parent != null && this.parent != null) {
- throw new IllegalStateException(getClass().getName()
- + " already has a parent.");
- }
-
- // Send detach event if the component have been connected to a window
- if (isAttached()) {
- detach();
- }
-
- // Connect to new parent
- this.parent = parent;
-
- // Send attach event if connected to an application
- if (isAttached()) {
- attach();
- }
- }
-
- @Override
- public ClientConnector getParent() {
- return parent;
- }
-
/*
* (non-Javadoc)
*
diff --git a/server/src/com/vaadin/server/AbstractExtension.java b/server/src/com/vaadin/server/AbstractExtension.java
index 00496aed4a..0387ad1b08 100644
--- a/server/src/com/vaadin/server/AbstractExtension.java
+++ b/server/src/com/vaadin/server/AbstractExtension.java
@@ -33,6 +33,8 @@ public abstract class AbstractExtension extends AbstractClientConnector
implements Extension {
private boolean previouslyAttached = false;
+ private ClientConnector parent;
+
/**
* Gets a type that the parent must be an instance of. Override this if the
* extension only support certain targets, e.g. if only TextFields can be
@@ -69,7 +71,7 @@ public abstract class AbstractExtension extends AbstractClientConnector
Class<? extends ClientConnector> supportedParentType = getSupportedParentType();
if (parent == null || supportedParentType.isInstance(parent)) {
- super.setParent(parent);
+ internalSetParent(parent);
previouslyAttached = true;
} else {
throw new IllegalArgumentException(getClass().getName()
@@ -79,4 +81,33 @@ public abstract class AbstractExtension extends AbstractClientConnector
}
}
+ /**
+ * Actually sets the parent and calls required listeners.
+ *
+ * @since 7.1
+ * @param parent
+ * The parent to set
+ */
+ private void internalSetParent(ClientConnector parent) {
+
+ // Send a detach event if the component is currently attached
+ if (isAttached()) {
+ detach();
+ }
+
+ // Connect to new parent
+ this.parent = parent;
+
+ // Send attach event if the component is now attached
+ if (isAttached()) {
+ attach();
+ }
+
+ }
+
+ @Override
+ public ClientConnector getParent() {
+ return parent;
+ }
+
}
diff --git a/server/src/com/vaadin/server/ClientConnector.java b/server/src/com/vaadin/server/ClientConnector.java
index 9e328bb6ef..3c06d5743c 100644
--- a/server/src/com/vaadin/server/ClientConnector.java
+++ b/server/src/com/vaadin/server/ClientConnector.java
@@ -27,8 +27,6 @@ import com.vaadin.event.ConnectorEvent;
import com.vaadin.event.ConnectorEventListener;
import com.vaadin.shared.Connector;
import com.vaadin.shared.communication.SharedState;
-import com.vaadin.ui.Component;
-import com.vaadin.ui.ComponentContainer;
import com.vaadin.ui.UI;
import com.vaadin.util.ReflectTools;
@@ -195,37 +193,6 @@ public interface ClientConnector extends Connector {
public void markAsDirtyRecursive();
/**
- * Sets the parent connector of the connector.
- *
- * <p>
- * This method automatically calls {@link #attach()} if the connector
- * becomes attached to the application, regardless of whether it was
- * attached previously. Conversely, if the parent is {@code null} and the
- * connector is attached to the application, {@link #detach()} is called for
- * the connector.
- * </p>
- * <p>
- * This method is rarely called directly. One of the
- * {@link ComponentContainer#addComponent(Component)} or
- * {@link AbstractClientConnector#addExtension(Extension)} methods are
- * normally used for adding connectors to a parent and they will call this
- * method implicitly.
- * </p>
- *
- * <p>
- * It is not possible to change the parent without first setting the parent
- * to {@code null}.
- * </p>
- *
- * @param parent
- * the parent connector
- * @throws IllegalStateException
- * if a parent is given even though the connector already has a
- * parent
- */
- public void setParent(ClientConnector parent);
-
- /**
* Checks if the connector is attached to a VaadinSession.
*
* @since 7.1
diff --git a/server/src/com/vaadin/server/Constants.java b/server/src/com/vaadin/server/Constants.java
index 7d3201efdf..0ea9de252a 100644
--- a/server/src/com/vaadin/server/Constants.java
+++ b/server/src/com/vaadin/server/Constants.java
@@ -65,7 +65,7 @@ public interface Constants {
+ " Widgetset version: %s\n"
+ "=================================================================";
- static final String REQUIRED_ATMOSPHERE_VERSION = "1.0.13";
+ static final String REQUIRED_ATMOSPHERE_VERSION = "1.0.14-2";
static final String INVALID_ATMOSPHERE_VERSION_WARNING = "\n"
+ "=================================================================\n"
diff --git a/server/src/com/vaadin/server/DragAndDropService.java b/server/src/com/vaadin/server/DragAndDropService.java
index cc571853fe..cef1bb86e7 100644
--- a/server/src/com/vaadin/server/DragAndDropService.java
+++ b/server/src/com/vaadin/server/DragAndDropService.java
@@ -64,6 +64,16 @@ public class DragAndDropService implements VariableOwner, ClientConnector {
public void changeVariables(Object source, Map<String, Object> variables) {
Object owner = variables.get("dhowner");
+ final Component sourceComponent = (Component) variables
+ .get("component");
+ if (sourceComponent != null && !sourceComponent.isEnabled()) {
+ // source component not supposed to be enabled
+ getLogger().warning(
+ "Client dropped from " + sourceComponent
+ + " even though it's disabled");
+ return;
+ }
+
// Validate drop handler owner
if (!(owner instanceof DropTarget)) {
getLogger()
@@ -74,6 +84,15 @@ public class DragAndDropService implements VariableOwner, ClientConnector {
// owner cannot be null here
DropTarget dropTarget = (DropTarget) owner;
+
+ if (!dropTarget.isEnabled()) {
+ getLogger()
+ .warning(
+ "Client dropped on " + owner
+ + " even though it's disabled");
+ return;
+ }
+
lastVisitId = (Integer) variables.get("visitId");
// request may be dropRequest or request during drag operation (commonly
@@ -296,12 +315,6 @@ public class DragAndDropService implements VariableOwner, ClientConnector {
}
@Override
- public void setParent(ClientConnector parent) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
public void attach() {
// TODO Auto-generated method stub
diff --git a/server/src/com/vaadin/server/Extension.java b/server/src/com/vaadin/server/Extension.java
index 2e632fc6c9..0f3d81598e 100644
--- a/server/src/com/vaadin/server/Extension.java
+++ b/server/src/com/vaadin/server/Extension.java
@@ -35,4 +35,25 @@ public interface Extension extends ClientConnector {
* removed, it cannot be attached again.
*/
void remove();
+
+ /**
+ * Sets the parent connector of the connector.
+ *
+ * This method automatically calls {@link #attach()} if the connector
+ * becomes attached to the session.
+ * <p>
+ * This method is rarely called directly.
+ * {@link AbstractClientConnector#addExtension(Extension)} is normally used
+ * for adding extensions to a parent and it will call this method
+ * implicitly.
+ * </p>
+ *
+ * @param parent
+ * the parent connector
+ * @throws IllegalStateException
+ * if a parent is given even though the connector already has a
+ * parent
+ */
+ public void setParent(ClientConnector parent);
+
}
diff --git a/server/src/com/vaadin/server/LocaleService.java b/server/src/com/vaadin/server/LocaleService.java
index 347c4da5c6..031ceb433c 100644
--- a/server/src/com/vaadin/server/LocaleService.java
+++ b/server/src/com/vaadin/server/LocaleService.java
@@ -19,6 +19,7 @@
*/
package com.vaadin.server;
+import java.io.Serializable;
import java.text.DateFormat;
import java.text.DateFormatSymbols;
import java.text.SimpleDateFormat;
@@ -37,7 +38,7 @@ import com.vaadin.ui.UI;
* @since 7.1
* @author Vaadin Ltd
*/
-public class LocaleService {
+public class LocaleService implements Serializable {
private UI ui;
diff --git a/server/src/com/vaadin/server/Page.java b/server/src/com/vaadin/server/Page.java
index 11553527e0..4dd7d34e38 100644
--- a/server/src/com/vaadin/server/Page.java
+++ b/server/src/com/vaadin/server/Page.java
@@ -306,7 +306,7 @@ public class Page implements Serializable {
}
}
- private static interface InjectedStyle {
+ private static interface InjectedStyle extends Serializable {
public void paint(int id, PaintTarget target) throws PaintException;
}
diff --git a/server/src/com/vaadin/server/VaadinServlet.java b/server/src/com/vaadin/server/VaadinServlet.java
index 05e3335c00..a9eb42578e 100644
--- a/server/src/com/vaadin/server/VaadinServlet.java
+++ b/server/src/com/vaadin/server/VaadinServlet.java
@@ -44,6 +44,7 @@ import com.vaadin.annotations.VaadinServletConfiguration.InitParameterName;
import com.vaadin.sass.internal.ScssStylesheet;
import com.vaadin.server.communication.ServletUIInitHandler;
import com.vaadin.shared.JsonConstants;
+import com.vaadin.ui.UI;
import com.vaadin.util.CurrentInstance;
@SuppressWarnings("serial")
@@ -69,6 +70,8 @@ public class VaadinServlet extends HttpServlet implements Constants {
super.init(servletConfig);
Properties initParameters = new Properties();
+ readUiFromEnclosingClass(initParameters);
+
readConfigurationAnnotation(initParameters);
// Read default parameters from server.xml
@@ -101,6 +104,15 @@ public class VaadinServlet extends HttpServlet implements Constants {
CurrentInstance.clearAll();
}
+ private void readUiFromEnclosingClass(Properties initParameters) {
+ Class<?> enclosingClass = getClass().getEnclosingClass();
+
+ if (enclosingClass != null && UI.class.isAssignableFrom(enclosingClass)) {
+ initParameters.put(VaadinSession.UI_PARAMETER,
+ enclosingClass.getName());
+ }
+ }
+
private void readConfigurationAnnotation(Properties initParameters)
throws ServletException {
VaadinServletConfiguration configAnnotation = UIProvider
@@ -742,11 +754,6 @@ public class VaadinServlet extends HttpServlet implements Constants {
private boolean serveOnTheFlyCompiledScss(String filename,
HttpServletRequest request, HttpServletResponse response,
ServletContext sc) throws IOException {
- if (getService().getDeploymentConfiguration().isProductionMode()) {
- // This is not meant for production mode.
- return false;
- }
-
if (!filename.endsWith(".css")) {
return false;
}
@@ -766,9 +773,21 @@ public class VaadinServlet extends HttpServlet implements Constants {
"Requested resource [{0}] not accessible in the VAADIN directory or access to it is forbidden.",
filename);
response.setStatus(HttpServletResponse.SC_FORBIDDEN);
+
+ // Handled, return true so no further processing is done
+ return true;
+ }
+ if (getService().getDeploymentConfiguration().isProductionMode()) {
+ // This is not meant for production mode.
+ getLogger()
+ .log(Level.INFO,
+ "Request for {0} not handled by sass compiler while in production mode",
+ filename);
+ response.setStatus(HttpServletResponse.SC_NOT_FOUND);
// Handled, return true so no further processing is done
return true;
}
+
synchronized (SCSS_MUTEX) {
String realFilename = sc.getRealPath(scssFilename);
ScssStylesheet scss = ScssStylesheet.get(realFilename);
diff --git a/server/src/com/vaadin/server/communication/AtmospherePushConnection.java b/server/src/com/vaadin/server/communication/AtmospherePushConnection.java
index 9e57ccb45d..e325550c4b 100644
--- a/server/src/com/vaadin/server/communication/AtmospherePushConnection.java
+++ b/server/src/com/vaadin/server/communication/AtmospherePushConnection.java
@@ -93,12 +93,13 @@ public class AtmospherePushConnection implements PushConnection {
}
private UI ui;
- private transient AtmosphereResource resource;
- private transient Future<String> outgoingMessage;
- private transient FragmentedMessage incomingMessage;
+ private AtmosphereResource resource;
+ private Future<String> outgoingMessage;
+ private FragmentedMessage incomingMessage;
- public AtmospherePushConnection(UI ui) {
+ public AtmospherePushConnection(UI ui, AtmosphereResource resource) {
this.ui = ui;
+ this.resource = resource;
}
@Override
@@ -176,21 +177,6 @@ public class AtmospherePushConnection implements PushConnection {
}
}
- /**
- * Associates this connection with the given AtmosphereResource. If there is
- * a push pending, commits it.
- *
- * @param resource
- * The AtmosphereResource representing the push channel.
- * @throws IOException
- */
- protected void connect(AtmosphereResource resource) throws IOException {
- this.resource = resource;
- }
-
- /**
- * Returns whether this connection is currently open.
- */
@Override
public boolean isConnected() {
return resource != null
@@ -215,6 +201,8 @@ public class AtmospherePushConnection implements PushConnection {
@Override
public void disconnect() {
+ assert isConnected();
+
if (outgoingMessage != null) {
// Wait for the last message to be sent before closing the
// connection (assumes that futures are completed in order)
diff --git a/server/src/com/vaadin/server/communication/PushConnection.java b/server/src/com/vaadin/server/communication/PushConnection.java
index bb88998402..7f78d1d48e 100644
--- a/server/src/com/vaadin/server/communication/PushConnection.java
+++ b/server/src/com/vaadin/server/communication/PushConnection.java
@@ -16,8 +16,6 @@
package com.vaadin.server.communication;
-import java.io.Serializable;
-
import com.vaadin.ui.UI;
/**
@@ -27,18 +25,20 @@ import com.vaadin.ui.UI;
* @author Vaadin Ltd
* @since 7.1
*/
-public interface PushConnection extends Serializable {
+public interface PushConnection {
/**
- * Pushes pending state changes and client RPC calls to the client. It is
- * NOT safe to invoke this method if not holding the session lock.
+ * Pushes pending state changes and client RPC calls to the client. Cannot
+ * be called if {@link #isConnected()} is false. It is NOT safe to invoke
+ * this method if not holding the session lock.
* <p>
* This is internal API; please use {@link UI#push()} instead.
*/
public void push();
/**
- * Disconnects the connection.
+ * Closes the connection. Cannot be called if {@link #isConnected()} is
+ * false.
*/
public void disconnect();
diff --git a/server/src/com/vaadin/server/communication/PushHandler.java b/server/src/com/vaadin/server/communication/PushHandler.java
index 7efcb8fd8c..6b853063a7 100644
--- a/server/src/com/vaadin/server/communication/PushHandler.java
+++ b/server/src/com/vaadin/server/communication/PushHandler.java
@@ -109,8 +109,7 @@ public class PushHandler implements AtmosphereHandler {
resource.suspend();
AtmospherePushConnection connection = new AtmospherePushConnection(
- ui);
- connection.connect(resource);
+ ui, resource);
ui.setPushConnection(connection);
}
@@ -305,12 +304,9 @@ public class PushHandler implements AtmosphereHandler {
private static AtmospherePushConnection getConnectionForUI(UI ui) {
PushConnection pushConnection = ui.getPushConnection();
if (pushConnection instanceof AtmospherePushConnection) {
- AtmospherePushConnection apc = (AtmospherePushConnection) pushConnection;
- if (apc.isConnected()) {
- return apc;
- }
+ assert pushConnection.isConnected();
+ return (AtmospherePushConnection) pushConnection;
}
-
return null;
}
@@ -374,11 +370,14 @@ public class PushHandler implements AtmosphereHandler {
*/
private static void sendRefreshAndDisconnect(AtmosphereResource resource)
throws IOException {
- AtmospherePushConnection connection = new AtmospherePushConnection(null);
- connection.connect(resource);
- connection.sendMessage(VaadinService.createCriticalNotificationJSON(
- null, null, null, null));
- connection.disconnect();
+ AtmospherePushConnection connection = new AtmospherePushConnection(
+ null, resource);
+ try {
+ connection.sendMessage(VaadinService
+ .createCriticalNotificationJSON(null, null, null, null));
+ } finally {
+ connection.disconnect();
+ }
}
private static final Logger getLogger() {
diff --git a/server/src/com/vaadin/server/communication/UidlRequestHandler.java b/server/src/com/vaadin/server/communication/UidlRequestHandler.java
index 3564aa65b5..d52c5e9fe0 100644
--- a/server/src/com/vaadin/server/communication/UidlRequestHandler.java
+++ b/server/src/com/vaadin/server/communication/UidlRequestHandler.java
@@ -75,7 +75,6 @@ public class UidlRequestHandler extends SynchronizedRequestHandler implements
}
checkWidgetsetVersion(request);
- String requestThemeName = request.getParameter("theme");
// repaint requested or session has timed out and new one is created
boolean repaintAll;
@@ -114,7 +113,6 @@ public class UidlRequestHandler extends SynchronizedRequestHandler implements
return true;
} finally {
stringWriter.close();
- requestThemeName = null;
}
return UIInitHandler.commitJsonResponse(request, response,
diff --git a/server/src/com/vaadin/ui/AbstractComponent.java b/server/src/com/vaadin/ui/AbstractComponent.java
index 9ff36a42d2..0bf27435fb 100644
--- a/server/src/com/vaadin/ui/AbstractComponent.java
+++ b/server/src/com/vaadin/ui/AbstractComponent.java
@@ -28,7 +28,6 @@ import java.util.regex.Pattern;
import com.vaadin.event.ActionManager;
import com.vaadin.event.ShortcutListener;
import com.vaadin.server.AbstractClientConnector;
-import com.vaadin.server.ClientConnector;
import com.vaadin.server.ComponentSizeValidator;
import com.vaadin.server.ErrorHandler;
import com.vaadin.server.ErrorMessage;
@@ -94,6 +93,8 @@ public abstract class AbstractComponent extends AbstractClientConnector
private boolean visible = true;
+ private HasComponents parent;
+
/* Constructor */
/**
@@ -451,17 +452,32 @@ public abstract class AbstractComponent extends AbstractClientConnector
*/
@Override
public HasComponents getParent() {
- return (HasComponents) super.getParent();
+ return parent;
}
@Override
- public void setParent(ClientConnector parent) {
- if (parent == null || parent instanceof HasComponents) {
- super.setParent(parent);
- } else {
- throw new IllegalArgumentException(
- "The parent of a Component must implement HasComponents, which "
- + parent.getClass() + " doesn't do.");
+ public void setParent(HasComponents parent) {
+ // If the parent is not changed, don't do anything
+ if (parent == this.parent) {
+ return;
+ }
+
+ if (parent != null && this.parent != null) {
+ throw new IllegalStateException(getClass().getName()
+ + " already has a parent.");
+ }
+
+ // Send a detach event if the component is currently attached
+ if (isAttached()) {
+ detach();
+ }
+
+ // Connect to new parent
+ this.parent = parent;
+
+ // Send attach event if the component is now attached
+ if (isAttached()) {
+ attach();
}
}
diff --git a/server/src/com/vaadin/ui/AbstractField.java b/server/src/com/vaadin/ui/AbstractField.java
index 606bf5fb21..6a52d6b849 100644
--- a/server/src/com/vaadin/ui/AbstractField.java
+++ b/server/src/com/vaadin/ui/AbstractField.java
@@ -740,35 +740,59 @@ public abstract class AbstractField<T> extends AbstractComponent implements
*/
private Object convertToModel(T fieldValue, Locale locale)
throws Converter.ConversionException {
- Class<?> modelType = null;
- Property pd = getPropertyDataSource();
- if (pd != null) {
- modelType = pd.getType();
- } else if (getConverter() != null) {
- modelType = getConverter().getModelType();
- }
+ Class<?> modelType = getModelType();
try {
return ConverterUtil.convertToModel(fieldValue,
(Class<Object>) modelType, getConverter(), locale);
} catch (ConversionException e) {
- throw new ConversionException(getConversionError(modelType), e);
+ throw new ConversionException(getConversionError(modelType, e), e);
+ }
+ }
+
+ /**
+ * Retrieves the type of the currently used data model. If the field has no
+ * data source then the model type of the converter is used.
+ *
+ * @since 7.1
+ * @return The type of the currently used data model or null if no data
+ * source or converter is set.
+ */
+ protected Class<?> getModelType() {
+ Property<?> pd = getPropertyDataSource();
+ if (pd != null) {
+ return pd.getType();
+ } else if (getConverter() != null) {
+ return getConverter().getModelType();
}
+ return null;
}
/**
- * Returns the conversion error with {0} replaced by the data source type.
+ * Returns the conversion error with {0} replaced by the data source type
+ * and {1} replaced by the exception (localized) message.
*
+ * @since 7.1
* @param dataSourceType
- * The type of the data source
+ * the type of the data source
+ * @param e
+ * a conversion exception which can provide additional
+ * information
* @return The value conversion error string with parameters replaced.
*/
- protected String getConversionError(Class<?> dataSourceType) {
- if (dataSourceType == null) {
- return getConversionError();
- } else {
- return getConversionError().replace("{0}",
+ protected String getConversionError(Class<?> dataSourceType,
+ ConversionException e) {
+ String conversionError = getConversionError();
+
+ if (dataSourceType != null) {
+ conversionError = conversionError.replace("{0}",
dataSourceType.getSimpleName());
}
+ if (e != null) {
+ conversionError = conversionError.replace("{1}",
+ e.getLocalizedMessage());
+ }
+
+ return conversionError;
}
/**
@@ -923,10 +947,10 @@ public abstract class AbstractField<T> extends AbstractComponent implements
if (getConverter() != null) {
try {
valueToValidate = getConverter().convertToModel(fieldValue,
- getLocale());
- } catch (Exception e) {
- throw new InvalidValueException(
- getConversionError(getConverter().getModelType()));
+ getModelType(), getLocale());
+ } catch (ConversionException e) {
+ throw new InvalidValueException(getConversionError(
+ getConverter().getModelType(), e));
}
}
@@ -1461,7 +1485,8 @@ public abstract class AbstractField<T> extends AbstractComponent implements
/**
* Sets the error that is shown if the field value cannot be converted to
* the data source type. If {0} is present in the message, it will be
- * replaced by the simple name of the data source type.
+ * replaced by the simple name of the data source type. If {1} is present in
+ * the message, it will be replaced by the ConversionException message.
*
* @param valueConversionError
* Message to be shown when conversion of the value fails
diff --git a/server/src/com/vaadin/ui/AbstractJavaScriptComponent.java b/server/src/com/vaadin/ui/AbstractJavaScriptComponent.java
index 0b3da768c9..6769b6e513 100644
--- a/server/src/com/vaadin/ui/AbstractJavaScriptComponent.java
+++ b/server/src/com/vaadin/ui/AbstractJavaScriptComponent.java
@@ -82,6 +82,16 @@ import com.vaadin.shared.ui.JavaScriptComponentState;
* <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 com.vaadin.client.ApplicationConnection#translateVaadinUri(String)}</li>
+ * <li><code>addResizeListener(element, callbackFunction)</code> - Registers a
+ * listener that gets notified whenever the size of the provided element
+ * changes. The listener is called with one parameter: an event object with the
+ * <code>element</code> property pointing to the element that has been resized.
+ * <li><code>removeResizeListener(element, callbackFunction)</code> -
+ * Unregisters a combination of an element and a listener that has previously
+ * been registered using <code>addResizeListener</code>. All registered
+ * listeners are automatically unregistered when this connector is unregistered,
+ * but this method can be use to to unregister a listener at an earlier point in
+ * time.
* </ul>
* The connector wrapper also supports these special functions:
* <ul>
diff --git a/server/src/com/vaadin/ui/Component.java b/server/src/com/vaadin/ui/Component.java
index 20958812fc..485327bb54 100644
--- a/server/src/com/vaadin/ui/Component.java
+++ b/server/src/com/vaadin/ui/Component.java
@@ -333,6 +333,32 @@ public interface Component extends ClientConnector, Sizeable, Serializable {
public void setVisible(boolean visible);
/**
+ * Sets the parent connector of the component.
+ *
+ * <p>
+ * This method automatically calls {@link #attach()} if the component
+ * becomes attached to the session, regardless of whether it was attached
+ * previously. Conversely, if the component currently is attached to the
+ * session, {@link #detach()} is called for the connector before attaching
+ * it to a new parent.
+ * </p>
+ * <p>
+ * This method is rarely called directly.
+ * {@link ComponentContainer#addComponent(Component)} or a
+ * {@link HasComponents} specific method is normally used for adding
+ * components to a parent and the used method will call this method
+ * implicitly.
+ * </p>
+ *
+ * @param parent
+ * the parent connector
+ * @throws IllegalStateException
+ * if a parent is given even though the connector already has a
+ * parent
+ */
+ public void setParent(HasComponents parent);
+
+ /**
* Gets the parent component of the component.
*
* <p>
diff --git a/server/src/com/vaadin/ui/Table.java b/server/src/com/vaadin/ui/Table.java
index 3d7cb42050..a688b2eb45 100644
--- a/server/src/com/vaadin/ui/Table.java
+++ b/server/src/com/vaadin/ui/Table.java
@@ -4011,7 +4011,8 @@ public class Table extends AbstractSelect implements Action.Container,
}
Object value = property.getValue();
if (converter != null) {
- return converter.convertToPresentation(value, getLocale());
+ return converter.convertToPresentation(value, String.class,
+ getLocale());
}
return (null != value) ? value.toString() : "";
}
diff --git a/server/src/com/vaadin/ui/UI.java b/server/src/com/vaadin/ui/UI.java
index 9f2039de72..e0811e51f7 100644
--- a/server/src/com/vaadin/ui/UI.java
+++ b/server/src/com/vaadin/ui/UI.java
@@ -411,12 +411,9 @@ public abstract class UI extends AbstractSingleComponentContainer implements
} else {
if (session == null) {
detach();
- if (pushConnection != null && pushConnection.isConnected()) {
- // Close the push connection when UI is detached. Otherwise
- // the push connection and possibly VaadinSession will live
- // on.
- pushConnection.disconnect();
- }
+ // Close the push connection when UI is detached. Otherwise the
+ // push connection and possibly VaadinSession will live on.
+ setPushConnection(null);
}
this.session = session;
}
@@ -536,7 +533,7 @@ public abstract class UI extends AbstractSingleComponentContainer implements
private Navigator navigator;
- private PushConnection pushConnection = null;
+ private transient PushConnection pushConnection = null;
private boolean hasPendingPush = false;
@@ -1072,7 +1069,7 @@ public abstract class UI extends AbstractSingleComponentContainer implements
boolean sessionExpired = (session == null || session.isClosing());
getRpcProxy(UIClientRpc.class).uiClosed(sessionExpired);
- if (getPushConnection() != null && getPushConnection().isConnected()) {
+ if (getPushConnection() != null) {
// Push the Rpc to the client. The connection will be closed when
// the UI is detached and cleaned up.
getPushConnection().push();
@@ -1342,19 +1339,24 @@ public abstract class UI extends AbstractSingleComponentContainer implements
/**
* Returns the internal push connection object used by this UI. This method
- * should only be called by the framework.
+ * should only be called by the framework. If the returned PushConnection is
+ * not null, it is guaranteed to have {@code isConnected() == true}.
*/
public PushConnection getPushConnection() {
+ assert (pushConnection == null || pushConnection.isConnected());
return pushConnection;
}
/**
* Sets the internal push connection object used by this UI. This method
- * should only be called by the framework.
+ * should only be called by the framework. If {@pushConnection} is not null,
+ * its {@code isConnected()} must be true.
*/
public void setPushConnection(PushConnection pushConnection) {
// If pushMode is disabled then there should never be a pushConnection
- assert (getPushConfiguration().getPushMode().isEnabled() || pushConnection == null);
+ assert (pushConnection == null || getPushConfiguration().getPushMode()
+ .isEnabled());
+ assert (pushConnection == null || pushConnection.isConnected());
if (pushConnection == this.pushConnection) {
return;
diff --git a/server/src/com/vaadin/ui/Window.java b/server/src/com/vaadin/ui/Window.java
index 9f64c9118e..700d0eb387 100644
--- a/server/src/com/vaadin/ui/Window.java
+++ b/server/src/com/vaadin/ui/Window.java
@@ -31,7 +31,6 @@ import com.vaadin.event.ShortcutAction;
import com.vaadin.event.ShortcutAction.KeyCode;
import com.vaadin.event.ShortcutAction.ModifierKey;
import com.vaadin.event.ShortcutListener;
-import com.vaadin.server.ClientConnector;
import com.vaadin.server.PaintException;
import com.vaadin.server.PaintTarget;
import com.vaadin.shared.MouseEventDetails;
@@ -139,7 +138,7 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier,
* )
*/
@Override
- public void setParent(ClientConnector parent) {
+ public void setParent(HasComponents parent) {
if (parent == null || parent instanceof UI) {
super.setParent(parent);
} else {