summaryrefslogtreecommitdiffstats
path: root/server/src/com
diff options
context:
space:
mode:
authorJohn Ahlroos <john@vaadin.com>2012-09-11 09:11:42 +0300
committerJohn Ahlroos <john@vaadin.com>2012-09-11 09:11:42 +0300
commitff56225f04d1ca67923fb2b05d37adc4907678da (patch)
treeaafaefb72784131c21bd387b7de42719a8cc9fa1 /server/src/com
parent2905256998b69b2da6cc5bfbbe2c9230d7cacd48 (diff)
parentdeb4d35b48e51318a961f02d2b6e5969c0875754 (diff)
downloadvaadin-framework-ff56225f04d1ca67923fb2b05d37adc4907678da.tar.gz
vaadin-framework-ff56225f04d1ca67923fb2b05d37adc4907678da.zip
Merge branch 'master' into html5-doctype
Diffstat (limited to 'server/src/com')
-rw-r--r--server/src/com/vaadin/DefaultDeploymentConfiguration.java17
-rw-r--r--server/src/com/vaadin/data/RangeOutOfContainerBoundsException.java169
-rw-r--r--server/src/com/vaadin/server/AbstractVaadinService.java13
-rw-r--r--server/src/com/vaadin/server/AddonContext.java3
-rw-r--r--server/src/com/vaadin/server/Page.java100
-rw-r--r--server/src/com/vaadin/server/VaadinPortletSession.java4
-rw-r--r--server/src/com/vaadin/server/VaadinSession.java109
-rw-r--r--server/src/com/vaadin/server/WebBrowser.java3
-rw-r--r--server/src/com/vaadin/ui/AbstractField.java83
-rw-r--r--server/src/com/vaadin/ui/UI.java20
10 files changed, 281 insertions, 240 deletions
diff --git a/server/src/com/vaadin/DefaultDeploymentConfiguration.java b/server/src/com/vaadin/DefaultDeploymentConfiguration.java
index 6159137cc3..fed558c5b5 100644
--- a/server/src/com/vaadin/DefaultDeploymentConfiguration.java
+++ b/server/src/com/vaadin/DefaultDeploymentConfiguration.java
@@ -22,6 +22,13 @@ import java.util.logging.Logger;
import com.vaadin.server.Constants;
import com.vaadin.server.DeploymentConfiguration;
+/**
+ * The default implementation of {@link DeploymentConfiguration} based on a base
+ * class for resolving system properties and a set of init parameters.
+ *
+ * @author Vaadin Ltd
+ * @since 7.0.0
+ */
public class DefaultDeploymentConfiguration implements DeploymentConfiguration {
private final Properties initParameters;
private boolean productionMode;
@@ -31,6 +38,16 @@ public class DefaultDeploymentConfiguration implements DeploymentConfiguration {
private boolean idleRootCleanupEnabled;
private final Class<?> systemPropertyBaseClass;
+ /**
+ * Create a new deployment configuration instance.
+ *
+ * @param systemPropertyBaseClass
+ * the class that should be used as a basis when reading system
+ * properties
+ * @param initParameters
+ * the init parameters that should make up the foundation for
+ * this configuration
+ */
public DefaultDeploymentConfiguration(Class<?> systemPropertyBaseClass,
Properties initParameters) {
this.initParameters = initParameters;
diff --git a/server/src/com/vaadin/data/RangeOutOfContainerBoundsException.java b/server/src/com/vaadin/data/RangeOutOfContainerBoundsException.java
deleted file mode 100644
index 43058e45d8..0000000000
--- a/server/src/com/vaadin/data/RangeOutOfContainerBoundsException.java
+++ /dev/null
@@ -1,169 +0,0 @@
-package com.vaadin.data;
-
-/**
- * A exception that indicates that the container is unable to return all of the
- * consecutive item ids requested by the caller. This can happen if the
- * container size has changed since the input parameters for
- * {@link Container.Indexed#getItemIds(int, int)} were computed or if the
- * requested range exceeds the containers size due to some other factor.<br>
- * <br>
- *
- * The exception can contain additional parameters for easier debugging. The
- * additional parameters are the <code>startIndex</code> and
- * <code>numberOfIds</code> which were given to
- * {@link Container.Indexed#getItemIds(int, int)} as well as the size of the
- * container when the fetch was executed. The container size can be retrieved
- * with {@link #getContainerCurrentSize()}. <br>
- * <br>
- *
- * The additional parameters are optional but the party that received the
- * exception can check whether or not these were set by calling
- * {@link #isAdditionalParametersSet()}.
- *
- * @since 7.0
- */
-public class RangeOutOfContainerBoundsException extends RuntimeException {
-
- private final int startIndex;
- private final int numberOfIds;
- private final int containerCurrentSize;
- private final boolean additionalParametersSet;
-
- // Discourage users to create exceptions without at least some kind of
- // message...
- private RangeOutOfContainerBoundsException() {
- super();
- startIndex = -1;
- numberOfIds = -1;
- containerCurrentSize = -1;
- additionalParametersSet = false;
- }
-
- public RangeOutOfContainerBoundsException(String message) {
- super(message);
- startIndex = -1;
- numberOfIds = -1;
- containerCurrentSize = -1;
- additionalParametersSet = false;
- }
-
- public RangeOutOfContainerBoundsException(String message,
- Throwable throwable) {
- super(message, throwable);
- startIndex = -1;
- numberOfIds = -1;
- containerCurrentSize = -1;
- additionalParametersSet = false;
- }
-
- public RangeOutOfContainerBoundsException(Throwable throwable) {
- super(throwable);
- startIndex = -1;
- numberOfIds = -1;
- containerCurrentSize = -1;
- additionalParametersSet = false;
- }
-
- /**
- * Create a new {@link RangeOutOfContainerBoundsException} with the
- * additional parameters:
- * <ul>
- * <li>startIndex - start index for the query</li>
- * <li>numberOfIds - the number of consecutive item ids to get</li>
- * <li>containerCurrentSize - the size of the container during the execution
- * of the query</li>
- * </ul>
- * given.
- *
- * @param message
- * @param startIndex
- * the given startIndex for the query
- * @param numberOfIds
- * the number of item ids requested
- * @param containerCurrentSize
- * the current size of the container
- */
- public RangeOutOfContainerBoundsException(String message, int startIndex,
- int numberOfIds, int containerCurrentSize) {
- super(message);
-
- this.startIndex = startIndex;
- this.numberOfIds = numberOfIds;
- this.containerCurrentSize = containerCurrentSize;
- additionalParametersSet = true;
- }
-
- /**
- * Create a new {@link RangeOutOfContainerBoundsException} with the given
- * query parameters set in the exception along with the containers current
- * size and a @link {@link Throwable}.
- *
- * @param message
- * @param startIndex
- * the given startIndex for the query
- * @param numberOfIds
- * the number of item ids queried for
- * @param containerCurrentSize
- * the current size of the container
- * @param throwable
- */
- public RangeOutOfContainerBoundsException(String message, int startIndex,
- int numberOfIds, int containerCurrentSize, Throwable throwable) {
- super(message, throwable);
-
- this.startIndex = startIndex;
- this.numberOfIds = numberOfIds;
- this.containerCurrentSize = containerCurrentSize;
- additionalParametersSet = true;
- }
-
- /**
- * Get the given startIndex for the query. Remember to check if this
- * parameter is set by calling {@link #isAdditionalParametersSet()}
- *
- * @return the startIndex given to the container
- */
- public int getStartIndex() {
- return startIndex;
- }
-
- /**
- * Get the number of item ids requested. Remember to check if this parameter
- * is set with {@link #isAdditionalParametersSet()}
- *
- * @return the number of item ids the container was ordered to fetch
- */
- public int getNumberOfIds() {
- return numberOfIds;
- }
-
- /**
- * Get the container size when the query was actually executed. Remember to
- * check if this parameter is set with {@link #isAdditionalParametersSet()}
- */
- public int getContainerCurrentSize() {
- return containerCurrentSize;
- }
-
- /**
- * Check whether or not the additional parameters for the exception were set
- * during creation or not.
- *
- * The additional parameters can be retrieved with: <br>
- * <ul>
- * <li> {@link #getStartIndex()}</li>
- * <li> {@link #getNumberOfIds()}</li>
- * <li> {@link #getContainerCurrentSize()}</li>
- * </ul>
- *
- * @return true if parameters are set, false otherwise.
- *
- * @see #RangeOutOfContainerBoundsException(String, int, int, int)
- * RangeOutOfContainerBoundsException(String, int, int, int) for more
- * details on the additional parameters
- */
- public boolean isAdditionalParametersSet() {
- return additionalParametersSet;
- }
-
-}
diff --git a/server/src/com/vaadin/server/AbstractVaadinService.java b/server/src/com/vaadin/server/AbstractVaadinService.java
index 6e14c1984b..7150fdf0da 100644
--- a/server/src/com/vaadin/server/AbstractVaadinService.java
+++ b/server/src/com/vaadin/server/AbstractVaadinService.java
@@ -20,11 +20,24 @@ import java.lang.reflect.Constructor;
import java.util.Iterator;
import java.util.ServiceLoader;
+/**
+ * Abstract implementation of VaadinService that takes care of those parts that
+ * are common to both servlets and portlets.
+ *
+ * @author Vaadin Ltd
+ * @since 7.0.0
+ */
public abstract class AbstractVaadinService implements VaadinService {
private AddonContext addonContext;
private final DeploymentConfiguration deploymentConfiguration;
+ /**
+ * Creates a new vaadin service based on a deployment configuration
+ *
+ * @param deploymentConfiguration
+ * the deployment configuration for the service
+ */
public AbstractVaadinService(DeploymentConfiguration deploymentConfiguration) {
this.deploymentConfiguration = deploymentConfiguration;
}
diff --git a/server/src/com/vaadin/server/AddonContext.java b/server/src/com/vaadin/server/AddonContext.java
index 606d3c3568..ddb8394468 100644
--- a/server/src/com/vaadin/server/AddonContext.java
+++ b/server/src/com/vaadin/server/AddonContext.java
@@ -16,6 +16,7 @@
package com.vaadin.server;
+import java.io.Serializable;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Iterator;
@@ -41,7 +42,7 @@ import com.vaadin.util.ReflectTools;
* @author Vaadin Ltd
* @since 7.0.0
*/
-public class AddonContext {
+public class AddonContext implements Serializable {
private static final Method APPLICATION_STARTED_METHOD = ReflectTools
.findMethod(ApplicationStartedListener.class, "applicationStarted",
ApplicationStartedEvent.class);
diff --git a/server/src/com/vaadin/server/Page.java b/server/src/com/vaadin/server/Page.java
index 9a0948edc8..ccc400341e 100644
--- a/server/src/com/vaadin/server/Page.java
+++ b/server/src/com/vaadin/server/Page.java
@@ -29,8 +29,10 @@ import com.vaadin.shared.ui.BorderStyle;
import com.vaadin.shared.ui.ui.PageClientRpc;
import com.vaadin.shared.ui.ui.UIConstants;
import com.vaadin.ui.JavaScript;
+import com.vaadin.ui.Link;
import com.vaadin.ui.Notification;
import com.vaadin.ui.UI;
+import com.vaadin.ui.UI.LegacyWindow;
import com.vaadin.util.ReflectTools;
public class Page implements Serializable {
@@ -132,6 +134,25 @@ public class Page implements Serializable {
/**
* Creates a new open resource.
*
+ * @param url
+ * The URL to open
+ * @param name
+ * The name of the target window
+ * @param width
+ * The width of the target window
+ * @param height
+ * The height of the target window
+ * @param border
+ * The border style of the target window
+ */
+ private OpenResource(String url, String name, int width, int height,
+ BorderStyle border) {
+ this(new ExternalResource(url), name, width, height, border);
+ }
+
+ /**
+ * Creates a new open resource.
+ *
* @param resource
* The resource to open
* @param name
@@ -550,19 +571,19 @@ public class Page implements Serializable {
}
/**
- * Opens the given resource in this uI. The contents of this UI is replaced
- * by the {@code Resource}.
+ * Navigates this page to the given URL. The contents of this page in the
+ * browser is replaced with whatever is returned for the given URL.
*
- * @param resource
- * the resource to show in this uI
+ * @param url
+ * the URL to show
*/
- public void open(Resource resource) {
- openList.add(new OpenResource(resource, null, -1, -1, BORDER_DEFAULT));
+ public void setLocation(String url) {
+ openList.add(new OpenResource(url, null, -1, -1, BORDER_DEFAULT));
uI.markAsDirty();
}
/**
- * Opens the given resource in a window with the given name.
+ * Opens the given URL in a window with the given name.
* <p>
* The supplied {@code windowName} is used as the target name in a
* window.open call in the client. This means that special values such as
@@ -570,47 +591,63 @@ public class Page implements Serializable {
* <code>null</code> window name is also a special case.
* </p>
* <p>
- * "", null and "_self" as {@code windowName} all causes the resource to be
+ * "", null and "_self" as {@code windowName} all causes the URL to be
* opened in the current window, replacing any old contents. For
* downloadable content you should avoid "_self" as "_self" causes the
* client to skip rendering of any other changes as it considers them
- * irrelevant (the page will be replaced by the resource). This can speed up
- * the opening of a resource, but it might also put the client side into an
- * inconsistent state if the window content is not completely replaced e.g.,
- * if the resource is downloaded instead of displayed in the browser.
+ * irrelevant (the page will be replaced by the response from the URL). This
+ * can speed up the opening of a URL, but it might also put the client side
+ * into an inconsistent state if the window content is not completely
+ * replaced e.g., if the URL is downloaded instead of displayed in the
+ * browser.
* </p>
* <p>
- * "_blank" as {@code windowName} causes the resource to always be opened in
- * a new window or tab (depends on the browser and browser settings).
+ * "_blank" as {@code windowName} causes the URL to always be opened in a
+ * new window or tab (depends on the browser and browser settings).
* </p>
* <p>
* "_top" and "_parent" as {@code windowName} works as specified by the HTML
* standard.
* </p>
* <p>
- * Any other {@code windowName} will open the resource in a window with that
+ * Any other {@code windowName} will open the URL in a window with that
* name, either by opening a new window/tab in the browser or by replacing
* the contents of an existing window with that name.
* </p>
+ * <p>
+ * Please note that opening a popup window in this way may be blocked by the
+ * browser's popup-blocker because the new browser window is opened when
+ * processing a response from the server. To avoid this, you should instead
+ * use {@link Link} for opening the window because browsers are more
+ * forgiving then the window is opened directly from a client-side click
+ * event.
+ * </p>
*
- * @param resource
- * the resource.
+ * @param url
+ * the URL to open.
* @param windowName
* the name of the window.
*/
- public void open(Resource resource, String windowName) {
- openList.add(new OpenResource(resource, windowName, -1, -1,
- BORDER_DEFAULT));
+ public void open(String url, String windowName) {
+ openList.add(new OpenResource(url, windowName, -1, -1, BORDER_DEFAULT));
uI.markAsDirty();
}
/**
- * Opens the given resource in a window with the given size, border and
- * name. For more information on the meaning of {@code windowName}, see
- * {@link #open(Resource, String)}.
+ * Opens the given URL in a window with the given size, border and name. For
+ * more information on the meaning of {@code windowName}, see
+ * {@link #open(String, String)}.
+ * <p>
+ * Please note that opening a popup window in this way may be blocked by the
+ * browser's popup-blocker because the new browser window is opened when
+ * processing a response from the server. To avoid this, you should instead
+ * use {@link Link} for opening the window because browsers are more
+ * forgiving then the window is opened directly from a client-side click
+ * event.
+ * </p>
*
- * @param resource
- * the resource.
+ * @param url
+ * the URL to open.
* @param windowName
* the name of the window.
* @param width
@@ -620,6 +657,19 @@ public class Page implements Serializable {
* @param border
* the border style of the window.
*/
+ public void open(String url, String windowName, int width, int height,
+ BorderStyle border) {
+ openList.add(new OpenResource(url, windowName, width, height, border));
+ uI.markAsDirty();
+ }
+
+ /**
+ * @deprecated only retained to maintain compatibility with
+ * LegacyWindow.open methods. See documentation for
+ * {@link LegacyWindow#open(Resource, String, int, int, BorderStyle)}
+ * for discussion about replacing API.
+ */
+ @Deprecated
public void open(Resource resource, String windowName, int width,
int height, BorderStyle border) {
openList.add(new OpenResource(resource, windowName, width, height,
diff --git a/server/src/com/vaadin/server/VaadinPortletSession.java b/server/src/com/vaadin/server/VaadinPortletSession.java
index 5bd94c623d..bb37bbbcf3 100644
--- a/server/src/com/vaadin/server/VaadinPortletSession.java
+++ b/server/src/com/vaadin/server/VaadinPortletSession.java
@@ -216,7 +216,7 @@ public class VaadinPortletSession extends VaadinSession {
if (actionUrl != null) {
eventActionDestinationMap.put(actionKey, name);
eventActionValueMap.put(actionKey, value);
- uI.getPage().open(new ExternalResource(actionUrl.toString()));
+ uI.getPage().setLocation(actionUrl.toString());
} else {
// this should never happen as we already know the response is a
// MimeResponse
@@ -263,7 +263,7 @@ public class VaadinPortletSession extends VaadinSession {
if (actionUrl != null) {
sharedParameterActionNameMap.put(actionKey, name);
sharedParameterActionValueMap.put(actionKey, value);
- uI.getPage().open(new ExternalResource(actionUrl.toString()));
+ uI.getPage().setLocation(actionUrl.toString());
} else {
// this should never happen as we already know the response is a
// MimeResponse
diff --git a/server/src/com/vaadin/server/VaadinSession.java b/server/src/com/vaadin/server/VaadinSession.java
index c6b2d91f29..a91c011ddf 100644
--- a/server/src/com/vaadin/server/VaadinSession.java
+++ b/server/src/com/vaadin/server/VaadinSession.java
@@ -204,6 +204,8 @@ public class VaadinSession implements HttpSessionBindingListener, Serializable {
private transient WrappedSession session;
+ private final Map<String, Object> attributes = new HashMap<String, Object>();
+
/**
* @see javax.servlet.http.HttpSessionBindingListener#valueBound(HttpSessionBindingEvent)
*/
@@ -1306,4 +1308,111 @@ public class VaadinSession implements HttpSessionBindingListener, Serializable {
return lock;
}
+ /**
+ * Stores a value in this vaadin session. This can be used to associate data
+ * with the current user so that it can be retrieved at a later point from
+ * some other part of the application. Setting the value to
+ * <code>null</code> clears the stored value.
+ *
+ * @see #getAttribute(String)
+ *
+ * @param name
+ * the name to associate the value with, can not be
+ * <code>null</code>
+ * @param value
+ * the value to associate with the name, or <code>null</code> to
+ * remove a previous association.
+ */
+ public void setAttribute(String name, Object value) {
+ if (name == null) {
+ throw new IllegalArgumentException("name can not be null");
+ }
+ if (value != null) {
+ attributes.put(name, value);
+ } else {
+ attributes.remove(name);
+ }
+ }
+
+ /**
+ * Stores a value in this vaadin session. This can be used to associate data
+ * with the current user so that it can be retrieved at a later point from
+ * some other part of the application. Setting the value to
+ * <code>null</code> clears the stored value.
+ * <p>
+ * The fully qualified name of the type is used as the name when storing the
+ * value. The outcome of calling this method is thus the same as if calling<br />
+ * <br />
+ * <code>setAttribute(type.getName(), value);</code>
+ *
+ * @see #getAttribute(Class)
+ * @see #setAttribute(String, Object)
+ *
+ * @param type
+ * the type that the stored value represents, can not be null
+ * @param value
+ * the value to associate with the type, or <code>null</code> to
+ * remove a previous association.
+ */
+ public <T> void setAttribute(Class<T> type, T value) {
+ if (type == null) {
+ throw new IllegalArgumentException("type can not be null");
+ }
+ if (value != null && !type.isInstance(value)) {
+ throw new IllegalArgumentException("value of type "
+ + type.getName() + " expected but got "
+ + value.getClass().getName());
+ }
+ setAttribute(type.getName(), value);
+ }
+
+ /**
+ * Gets a stored attribute value. If a value has been stored for the
+ * session, that value is returned. If no value is stored for the name,
+ * <code>null</code> is returned.
+ *
+ * @see #setAttribute(String, Object)
+ *
+ * @param name
+ * the name of the value to get, can not be <code>null</code>.
+ * @return the value, or <code>null</code> if no value has been stored or if
+ * it has been set to null.
+ */
+ public Object getAttribute(String name) {
+ if (name == null) {
+ throw new IllegalArgumentException("name can not be null");
+ }
+ return attributes.get(name);
+ }
+
+ /**
+ * Gets a stored attribute value. If a value has been stored for the
+ * session, that value is returned. If no value is stored for the name,
+ * <code>null</code> is returned.
+ * <p>
+ * The fully qualified name of the type is used as the name when getting the
+ * value. The outcome of calling this method is thus the same as if calling<br />
+ * <br />
+ * <code>getAttribute(type.getName());</code>
+ *
+ * @see #setAttribute(Class, Object)
+ * @see #getAttribute(String)
+ *
+ * @param type
+ * the type of the value to get, can not be <code>null</code>.
+ * @return the value, or <code>null</code> if no value has been stored or if
+ * it has been set to null.
+ */
+ public <T> T getAttribute(Class<T> type) {
+ if (type == null) {
+ throw new IllegalArgumentException("type can not be null");
+ }
+ Object value = getAttribute(type.getName());
+ if (value == null) {
+ return null;
+ } else {
+ return type.cast(value);
+ }
+ }
+
}
diff --git a/server/src/com/vaadin/server/WebBrowser.java b/server/src/com/vaadin/server/WebBrowser.java
index 9e29e957d9..6a377a3de9 100644
--- a/server/src/com/vaadin/server/WebBrowser.java
+++ b/server/src/com/vaadin/server/WebBrowser.java
@@ -16,6 +16,7 @@
package com.vaadin.server;
+import java.io.Serializable;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;
@@ -29,7 +30,7 @@ import com.vaadin.shared.VBrowserDetails;
*
* @author Vaadin Ltd.
*/
-public class WebBrowser {
+public class WebBrowser implements Serializable {
private int screenHeight = 0;
private int screenWidth = 0;
diff --git a/server/src/com/vaadin/ui/AbstractField.java b/server/src/com/vaadin/ui/AbstractField.java
index f673babc26..e7d6d9a4ec 100644
--- a/server/src/com/vaadin/ui/AbstractField.java
+++ b/server/src/com/vaadin/ui/AbstractField.java
@@ -282,43 +282,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements
*/
@Override
public void discard() throws Buffered.SourceException {
- if (dataSource != null) {
-
- // Gets the correct value from datasource
- T newFieldValue;
- try {
-
- // Discards buffer by overwriting from datasource
- newFieldValue = convertFromDataSource(getDataSourceValue());
-
- // If successful, remove set the buffering state to be ok
- if (getCurrentBufferedSourceException() != null) {
- setCurrentBufferedSourceException(null);
- }
- } catch (final Throwable e) {
- // FIXME: What should really be done here if conversion fails?
-
- // Sets the buffering state
- currentBufferedSourceException = new Buffered.SourceException(
- this, e);
- markAsDirty();
-
- // Throws the source exception
- throw currentBufferedSourceException;
- }
-
- final boolean wasModified = isModified();
- setModified(false);
-
- // If the new value differs from the previous one
- if (!equals(newFieldValue, getInternalValue())) {
- setInternalValue(newFieldValue);
- fireValueChange(false);
- } else if (wasModified) {
- // If the value did not change, but the modification status did
- markAsDirty();
- }
- }
+ updateValueFromDataSource();
}
/**
@@ -417,7 +381,8 @@ public abstract class AbstractField<T> extends AbstractComponent implements
public String toString() {
logger.warning("You are using AbstractField.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).");
final Object value = getFieldValue();
if (value == null) {
return null;
@@ -1323,7 +1288,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements
addPropertyListeners();
if (!isModified() && !isBuffered()) {
// Update value from data source
- discard();
+ updateValueFromDataSource();
}
}
}
@@ -1540,6 +1505,46 @@ public abstract class AbstractField<T> extends AbstractComponent implements
}
}
+ private void updateValueFromDataSource() {
+ if (dataSource != null) {
+
+ // Gets the correct value from datasource
+ T newFieldValue;
+ try {
+
+ // Discards buffer by overwriting from datasource
+ newFieldValue = convertFromDataSource(getDataSourceValue());
+
+ // If successful, remove set the buffering state to be ok
+ if (getCurrentBufferedSourceException() != null) {
+ setCurrentBufferedSourceException(null);
+ }
+ } catch (final Throwable e) {
+ // FIXME: What should really be done here if conversion fails?
+
+ // Sets the buffering state
+ currentBufferedSourceException = new Buffered.SourceException(
+ this, e);
+ markAsDirty();
+
+ // Throws the source exception
+ throw currentBufferedSourceException;
+ }
+
+ final boolean wasModified = isModified();
+ setModified(false);
+
+ // If the new value differs from the previous one
+ if (!equals(newFieldValue, getInternalValue())) {
+ setInternalValue(newFieldValue);
+ fireValueChange(false);
+ } else if (wasModified) {
+ // If the value did not change, but the modification status did
+ markAsDirty();
+ }
+ }
+ }
+
/**
* Gets the converter used to convert the property data source value to the
* field value.
diff --git a/server/src/com/vaadin/ui/UI.java b/server/src/com/vaadin/ui/UI.java
index ef77142312..adb2a63c2e 100644
--- a/server/src/com/vaadin/ui/UI.java
+++ b/server/src/com/vaadin/ui/UI.java
@@ -222,11 +222,11 @@ public abstract class UI extends AbstractComponentContainer implements
* @param resource
* the resource to show in this UI
*
- * @deprecated As of 7.0, use getPage().open instead
+ * @deprecated As of 7.0, use getPage().setLocation instead
*/
@Deprecated
public void open(Resource resource) {
- getPage().open(resource);
+ open(resource, null);
}
/* ********************************************************************* */
@@ -264,6 +264,13 @@ public abstract class UI extends AbstractComponentContainer implements
* that name, either by opening a new window/tab in the browser or by
* replacing the contents of an existing window with that name.
* </p>
+ * <p>
+ * As of Vaadin 7.0.0, the functionality for opening a Resource in a
+ * Page has been replaced with similar methods based on a String URL.
+ * This is because the usage of Resource is problematic with memory
+ * management and with security features in some browsers. Is is
+ * recommended to instead use {@link Link} for starting downloads.
+ * </p>
*
* @param resource
* the resource.
@@ -273,13 +280,20 @@ public abstract class UI extends AbstractComponentContainer implements
*/
@Deprecated
public void open(Resource resource, String windowName) {
- getPage().open(resource, windowName);
+ open(resource, windowName, -1, -1, Page.BORDER_DEFAULT);
}
/**
* Opens the given resource in a window with the given size, border and
* name. For more information on the meaning of {@code windowName}, see
* {@link #open(Resource, String)}.
+ * <p>
+ * As of Vaadin 7.0.0, the functionality for opening a Resource in a
+ * Page has been replaced with similar methods based on a String URL.
+ * This is because the usage of Resource is problematic with memory
+ * management and with security features in some browsers. Is is
+ * recommended to instead use {@link Link} for starting downloads.
+ * </p>
*
* @param resource
* the resource.