summaryrefslogtreecommitdiffstats
path: root/server/src/com/vaadin/ui
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/com/vaadin/ui')
-rw-r--r--server/src/com/vaadin/ui/AbstractComponent.java29
-rw-r--r--server/src/com/vaadin/ui/AbstractField.java2
-rw-r--r--server/src/com/vaadin/ui/Component.java25
-rw-r--r--server/src/com/vaadin/ui/ConnectorTracker.java2
-rw-r--r--server/src/com/vaadin/ui/Label.java2
-rw-r--r--server/src/com/vaadin/ui/LoginForm.java6
-rw-r--r--server/src/com/vaadin/ui/Table.java2
-rw-r--r--server/src/com/vaadin/ui/UI.java53
8 files changed, 46 insertions, 75 deletions
diff --git a/server/src/com/vaadin/ui/AbstractComponent.java b/server/src/com/vaadin/ui/AbstractComponent.java
index e6cc80f1cf..85938c4fe3 100644
--- a/server/src/com/vaadin/ui/AbstractComponent.java
+++ b/server/src/com/vaadin/ui/AbstractComponent.java
@@ -259,7 +259,7 @@ public abstract class AbstractComponent extends AbstractClientConnector
if (parent != null) {
return parent.getLocale();
}
- final VaadinSession app = getApplication();
+ final VaadinSession app = getSession();
if (app != null) {
return app.getLocale();
}
@@ -616,7 +616,7 @@ public abstract class AbstractComponent extends AbstractClientConnector
*/
protected void focus() {
if (this instanceof Focusable) {
- final VaadinSession app = getApplication();
+ final VaadinSession app = getSession();
if (app != null) {
getUI().setFocusedComponent((Focusable) this);
delayedFocus = false;
@@ -627,31 +627,6 @@ public abstract class AbstractComponent extends AbstractClientConnector
}
/**
- * Gets the application object to which the component is attached.
- *
- * <p>
- * The method will return {@code null} if the component is not currently
- * attached to an application. This is often a problem in constructors of
- * regular components and in the initializers of custom composite
- * components. A standard workaround is to move the problematic
- * initialization to {@link #attach()}, as described in the documentation of
- * the method.
- * </p>
- * <p>
- * <b>This method is not meant to be overridden. Due to CDI requirements we
- * cannot declare it as final even though it should be final.</b>
- * </p>
- *
- * @return the parent application of the component or <code>null</code>.
- * @see #attach()
- */
- @Override
- public VaadinSession getApplication() {
- // Just make method inherited from Component interface public
- return super.getApplication();
- }
-
- /**
* Build CSS compatible string representation of height.
*
* @return CSS height
diff --git a/server/src/com/vaadin/ui/AbstractField.java b/server/src/com/vaadin/ui/AbstractField.java
index 548cb06c8f..f673babc26 100644
--- a/server/src/com/vaadin/ui/AbstractField.java
+++ b/server/src/com/vaadin/ui/AbstractField.java
@@ -697,7 +697,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements
*/
public void setConverter(Class<?> datamodelType) {
Converter<T, ?> c = (Converter<T, ?>) ConverterUtil.getConverter(
- getType(), datamodelType, getApplication());
+ getType(), datamodelType, getSession());
setConverter(c);
}
diff --git a/server/src/com/vaadin/ui/Component.java b/server/src/com/vaadin/ui/Component.java
index 812edbb8d2..492e0c25c6 100644
--- a/server/src/com/vaadin/ui/Component.java
+++ b/server/src/com/vaadin/ui/Component.java
@@ -26,7 +26,6 @@ import com.vaadin.server.ClientConnector;
import com.vaadin.server.ErrorMessage;
import com.vaadin.server.Resource;
import com.vaadin.server.Sizeable;
-import com.vaadin.server.VaadinSession;
import com.vaadin.server.VariableOwner;
/**
@@ -522,34 +521,12 @@ public interface Component extends ClientConnector, Sizeable, Serializable {
public UI getUI();
/**
- * Gets the application object to which the component is attached.
- *
- * <p>
- * The method will return {@code null} if the component is not currently
- * attached to an application.
- * </p>
- *
- * <p>
- * Getting a null value is often a problem in constructors of regular
- * components and in the initializers of custom composite components. A
- * standard workaround is to use {@link VaadinSession#getCurrent()} to
- * retrieve the application instance that the current request relates to.
- * Another way is to move the problematic initialization to
- * {@link #attach()}, as described in the documentation of the method.
- * </p>
- *
- * @return the parent application of the component or <code>null</code>.
- * @see #attach()
- */
- public VaadinSession getApplication();
-
- /**
* {@inheritDoc}
*
* <p>
* Reimplementing the {@code attach()} method is useful for tasks that need
* to get a reference to the parent, window, or application object with the
- * {@link #getParent()}, {@link #getUI()}, and {@link #getApplication()}
+ * {@link #getParent()}, {@link #getUI()}, and {@link #getSession()}
* methods. A component does not yet know these objects in the constructor,
* so in such case, the methods will return {@code null}. For example, the
* following is invalid:
diff --git a/server/src/com/vaadin/ui/ConnectorTracker.java b/server/src/com/vaadin/ui/ConnectorTracker.java
index c84b75ca51..d454df98ee 100644
--- a/server/src/com/vaadin/ui/ConnectorTracker.java
+++ b/server/src/com/vaadin/ui/ConnectorTracker.java
@@ -152,7 +152,7 @@ public class ConnectorTracker implements Serializable {
}
private void removeFromGlobalResourceHandler(ClientConnector connector) {
- GlobalResourceHandler globalResourceHandler = uI.getApplication()
+ GlobalResourceHandler globalResourceHandler = uI.getSession()
.getGlobalResourceHandler(false);
// Nothing to do if there is no handler
if (globalResourceHandler != null) {
diff --git a/server/src/com/vaadin/ui/Label.java b/server/src/com/vaadin/ui/Label.java
index ff4a5dcb07..53b618a87f 100644
--- a/server/src/com/vaadin/ui/Label.java
+++ b/server/src/com/vaadin/ui/Label.java
@@ -254,7 +254,7 @@ public class Label extends AbstractComponent implements Property<String>,
newDataSource.getType())) {
// Try to find a converter
Converter<String, ?> c = ConverterUtil.getConverter(String.class,
- newDataSource.getType(), getApplication());
+ newDataSource.getType(), getSession());
setConverter(c);
}
dataSource = newDataSource;
diff --git a/server/src/com/vaadin/ui/LoginForm.java b/server/src/com/vaadin/ui/LoginForm.java
index 1d0c5c41b6..b57b271778 100644
--- a/server/src/com/vaadin/ui/LoginForm.java
+++ b/server/src/com/vaadin/ui/LoginForm.java
@@ -132,7 +132,7 @@ public class LoginForm extends CustomComponent {
* @return byte array containing login page html
*/
protected byte[] getLoginHTML() {
- String appUri = getApplication().getURL().toString();
+ String appUri = getSession().getURL().toString();
try {
return ("<!DOCTYPE html PUBLIC \"-//W3C//DTD "
@@ -186,13 +186,13 @@ public class LoginForm extends CustomComponent {
@Override
public void attach() {
super.attach();
- getApplication().addRequestHandler(requestHandler);
+ getSession().addRequestHandler(requestHandler);
iframe.setSource(loginPage);
}
@Override
public void detach() {
- getApplication().removeRequestHandler(requestHandler);
+ getSession().removeRequestHandler(requestHandler);
super.detach();
}
diff --git a/server/src/com/vaadin/ui/Table.java b/server/src/com/vaadin/ui/Table.java
index 65189fed0c..e0469f6522 100644
--- a/server/src/com/vaadin/ui/Table.java
+++ b/server/src/com/vaadin/ui/Table.java
@@ -3717,7 +3717,7 @@ public class Table extends AbstractSelect implements Action.Container,
converter = getConverter(colId);
} else {
ConverterUtil.getConverter(String.class, property.getType(),
- getApplication());
+ getSession());
}
Object value = property.getValue();
if (converter != null) {
diff --git a/server/src/com/vaadin/ui/UI.java b/server/src/com/vaadin/ui/UI.java
index e2d79454f6..0b376f54c1 100644
--- a/server/src/com/vaadin/ui/UI.java
+++ b/server/src/com/vaadin/ui/UI.java
@@ -27,7 +27,6 @@ import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.Map;
-import com.vaadin.LegacyApplication;
import com.vaadin.event.Action;
import com.vaadin.event.Action.Handler;
import com.vaadin.event.ActionManager;
@@ -174,7 +173,7 @@ public abstract class UI extends AbstractComponentContainer implements
public void setName(String name) {
this.name = name;
// The name can not be changed in application
- if (getApplication() != null) {
+ if (getSession() != null) {
throw new IllegalStateException(
"Window name can not be changed while "
+ "the window is in application");
@@ -193,7 +192,7 @@ public abstract class UI extends AbstractComponentContainer implements
* to an application
*/
public URL getURL() {
- VaadinSession application = getApplication();
+ VaadinSession application = getSession();
if (application == null) {
return null;
}
@@ -424,7 +423,7 @@ public abstract class UI extends AbstractComponentContainer implements
/**
* The application to which this UI belongs
*/
- private VaadinSession application;
+ private VaadinSession session;
/**
* List of windows in this UI.
@@ -563,9 +562,29 @@ public abstract class UI extends AbstractComponentContainer implements
throw new UnsupportedOperationException();
}
+ /**
+ * Gets the application object to which the component is attached.
+ *
+ * <p>
+ * The method will return {@code null} if the component is not currently
+ * attached to an application.
+ * </p>
+ *
+ * <p>
+ * Getting a null value is often a problem in constructors of regular
+ * components and in the initializers of custom composite components. A
+ * standard workaround is to use {@link VaadinSession#getCurrent()} to
+ * retrieve the application instance that the current request relates to.
+ * Another way is to move the problematic initialization to
+ * {@link #attach()}, as described in the documentation of the method.
+ * </p>
+ *
+ * @return the parent application of the component or <code>null</code>.
+ * @see #attach()
+ */
@Override
- public VaadinSession getApplication() {
- return application;
+ public VaadinSession getSession() {
+ return session;
}
@Override
@@ -676,25 +695,25 @@ public abstract class UI extends AbstractComponentContainer implements
* This method is mainly intended for internal use by the framework.
* </p>
*
- * @param application
+ * @param session
* the application to set
*
* @throws IllegalStateException
* if the application has already been set
*
- * @see #getApplication()
+ * @see #getSession()
*/
- public void setApplication(VaadinSession application) {
- if ((application == null) == (this.application == null)) {
+ public void setSession(VaadinSession session) {
+ if ((session == null) == (this.session == null)) {
throw new IllegalStateException("Application has already been set");
} else {
- if (application == null) {
+ if (session == null) {
detach();
}
- this.application = application;
+ this.session = session;
}
- if (application != null) {
+ if (session != null) {
attach();
}
}
@@ -703,8 +722,8 @@ public abstract class UI extends AbstractComponentContainer implements
* Gets the id of the UI, used to identify this UI within its application
* when processing requests. The UI id should be present in every request to
* the server that originates from this UI.
- * {@link VaadinSession#getUIForRequest(WrappedRequest)} uses this id to find
- * the route to which the request belongs.
+ * {@link VaadinSession#getUIForRequest(WrappedRequest)} uses this id to
+ * find the route to which the request belongs.
*
* @return
*/
@@ -732,7 +751,7 @@ public abstract class UI extends AbstractComponentContainer implements
throw new NullPointerException("Argument must not be null");
}
- if (window.getApplication() != null) {
+ if (window.getUI() != null && window.getUI().getSession() != null) {
throw new IllegalArgumentException(
"Window is already attached to an application.");
}
@@ -937,7 +956,7 @@ public abstract class UI extends AbstractComponentContainer implements
throw new IllegalStateException("UI id has already been defined");
}
this.uiId = uiId;
- theme = getApplication().getUiProvider(request, getClass())
+ theme = getSession().getUiProvider(request, getClass())
.getThemeForUI(request, getClass());
getPage().init(request);