Browse Source

Remove getApplication() and add getSession() (#9402)

tags/7.0.0.beta1
Leif Åstrand 11 years ago
parent
commit
cc3ddcac95
33 changed files with 122 additions and 135 deletions
  1. 4
    4
      server/src/com/vaadin/LegacyApplication.java
  2. 1
    1
      server/src/com/vaadin/event/dd/acceptcriteria/SourceIs.java
  3. 7
    7
      server/src/com/vaadin/server/AbstractClientConnector.java
  4. 7
    7
      server/src/com/vaadin/server/AbstractCommunicationManager.java
  5. 1
    1
      server/src/com/vaadin/server/CommunicationManager.java
  6. 1
    1
      server/src/com/vaadin/server/ConnectorResourceHandler.java
  7. 1
    1
      server/src/com/vaadin/server/JsonPaintTarget.java
  8. 1
    1
      server/src/com/vaadin/server/Page.java
  9. 1
    1
      server/src/com/vaadin/server/PortletCommunicationManager.java
  10. 1
    1
      server/src/com/vaadin/server/ResourceReference.java
  11. 2
    2
      server/src/com/vaadin/server/VaadinSession.java
  12. 2
    27
      server/src/com/vaadin/ui/AbstractComponent.java
  13. 1
    1
      server/src/com/vaadin/ui/AbstractField.java
  14. 1
    24
      server/src/com/vaadin/ui/Component.java
  15. 1
    1
      server/src/com/vaadin/ui/ConnectorTracker.java
  16. 1
    1
      server/src/com/vaadin/ui/Label.java
  17. 3
    3
      server/src/com/vaadin/ui/LoginForm.java
  18. 1
    1
      server/src/com/vaadin/ui/Table.java
  19. 36
    17
      server/src/com/vaadin/ui/UI.java
  20. 2
    2
      server/tests/src/com/vaadin/tests/data/converter/ConverterFactory.java
  21. 1
    1
      server/tests/src/com/vaadin/tests/server/TestStreamVariableMapping.java
  22. 1
    1
      server/tests/src/com/vaadin/tests/server/component/abstractfield/AbstractFieldValueConversions.java
  23. 2
    2
      server/tests/src/com/vaadin/tests/server/component/abstractfield/RemoveListenersOnDetach.java
  24. 31
    16
      server/tests/src/com/vaadin/tests/server/component/window/AttachDetachWindow.java
  25. 1
    1
      uitest/src/com/vaadin/tests/StressComponentsInTable.java
  26. 1
    1
      uitest/src/com/vaadin/tests/TestForUpload.java
  27. 1
    1
      uitest/src/com/vaadin/tests/application/ApplicationCloseTest.java
  28. 1
    1
      uitest/src/com/vaadin/tests/components/AbstractTestUI.java
  29. 2
    2
      uitest/src/com/vaadin/tests/components/table/TableFirstRowFlicker.java
  30. 2
    1
      uitest/src/com/vaadin/tests/components/textfield/SelectionAndCursorPosition.java
  31. 1
    1
      uitest/src/com/vaadin/tests/layouts/ComplexGLColumnExpansionWithColSpan.java
  32. 1
    1
      uitest/src/com/vaadin/tests/minitutorials/v7a1/CustomConverterFactoryUI.java
  33. 2
    2
      uitest/src/com/vaadin/tests/minitutorials/v7a1/DynamicImageUI.java

+ 4
- 4
server/src/com/vaadin/LegacyApplication.java View File

@@ -68,9 +68,9 @@ public abstract class LegacyApplication extends AbstractUIProvider implements
if (this.mainWindow != null) {
throw new IllegalStateException("mainWindow has already been set");
}
if (mainWindow.getApplication() == null) {
mainWindow.setApplication(VaadinSession.getCurrent());
} else if (mainWindow.getApplication() != VaadinSession.getCurrent()) {
if (mainWindow.getSession() == null) {
mainWindow.setSession(VaadinSession.getCurrent());
} else if (mainWindow.getSession() != VaadinSession.getCurrent()) {
throw new IllegalStateException(
"mainWindow is attached to another application");
}
@@ -242,7 +242,7 @@ public abstract class LegacyApplication extends AbstractUIProvider implements
}

legacyUINames.put(uI.getName(), uI);
uI.setApplication(VaadinSession.getCurrent());
uI.setSession(VaadinSession.getCurrent());
}

/**

+ 1
- 1
server/src/com/vaadin/event/dd/acceptcriteria/SourceIs.java View File

@@ -48,7 +48,7 @@ public class SourceIs extends ClientSideCriterion {
int paintedComponents = 0;
for (int i = 0; i < components.length; i++) {
Component c = components[i];
if (c.getApplication() != null) {
if (c.getUI() != null && c.getUI().getSession() != null) {
target.addAttribute("component" + paintedComponents++, c);
} else {
Logger.getLogger(SourceIs.class.getName())

+ 7
- 7
server/src/com/vaadin/server/AbstractClientConnector.java View File

@@ -342,11 +342,11 @@ public abstract class AbstractClientConnector implements ClientConnector {
@Override
public String getConnectorId() {
if (connectorId == null) {
if (getApplication() == null) {
if (getSession() == null) {
throw new RuntimeException(
"Component must be attached to an application when getConnectorId() is called for the first time");
}
connectorId = getApplication().createConnectorId(this);
connectorId = getSession().createConnectorId(this);
}
return connectorId;
}
@@ -357,12 +357,12 @@ public abstract class AbstractClientConnector implements ClientConnector {
*
* @return The connector's application, or <code>null</code> if not attached
*/
protected VaadinSession getApplication() {
protected VaadinSession getSession() {
UI uI = getUI();
if (uI == null) {
return null;
} else {
return uI.getApplication();
return uI.getSession();
}
}

@@ -501,7 +501,7 @@ public abstract class AbstractClientConnector implements ClientConnector {
}

// Send detach event if the component have been connected to a window
if (getApplication() != null) {
if (getSession() != null) {
detach();
}

@@ -509,7 +509,7 @@ public abstract class AbstractClientConnector implements ClientConnector {
this.parent = parent;

// Send attach event if connected to an application
if (getApplication() != null) {
if (getSession() != null) {
attach();
}
}
@@ -535,7 +535,7 @@ public abstract class AbstractClientConnector implements ClientConnector {
* {@inheritDoc}
*
* <p>
* The {@link #getApplication()} and {@link #getUI()} methods might return
* The {@link #getSession()} and {@link #getUI()} methods might return
* <code>null</code> after this method is called.
* </p>
*/

+ 7
- 7
server/src/com/vaadin/server/AbstractCommunicationManager.java View File

@@ -676,7 +676,7 @@ public abstract class AbstractCommunicationManager implements Serializable {
}

sb.append("\nComponent hierarchy:\n");
VaadinSession application2 = component.getApplication();
VaadinSession application2 = component.getUI().getSession();
sb.append(application2.getClass().getName());
sb.append(".");
sb.append(application2.getClass().getSimpleName());
@@ -789,7 +789,7 @@ public abstract class AbstractCommunicationManager implements Serializable {
final PrintWriter outWriter, UI ui, boolean analyzeLayouts)
throws PaintException, JSONException {
ArrayList<ClientConnector> dirtyVisibleConnectors = new ArrayList<ClientConnector>();
VaadinSession application = ui.getApplication();
VaadinSession application = ui.getSession();
// Paints components
ConnectorTracker uiConnectorTracker = ui.getConnectorTracker();
getLogger().log(Level.FINE, "* Creating response to client");
@@ -1697,7 +1697,7 @@ public abstract class AbstractCommunicationManager implements Serializable {
if (connector instanceof Component) {
errorComponent = (Component) connector;
}
handleChangeVariablesError(uI.getApplication(),
handleChangeVariablesError(uI.getSession(),
errorComponent, realException, null);
}
} else {
@@ -1729,7 +1729,7 @@ public abstract class AbstractCommunicationManager implements Serializable {
errorComponent = (Component) dropHandlerOwner;
}
}
handleChangeVariablesError(uI.getApplication(),
handleChangeVariablesError(uI.getSession(),
errorComponent, e, changes);
}
}
@@ -2154,8 +2154,8 @@ public abstract class AbstractCommunicationManager implements Serializable {
* Ends the Application.
*
* The browser is redirected to the Application logout URL set with
* {@link VaadinSession#setLogoutURL(String)}, or to the application URL if no
* logout URL is given.
* {@link VaadinSession#setLogoutURL(String)}, or to the application URL if
* no logout URL is given.
*
* @param request
* the request instance.
@@ -2450,7 +2450,7 @@ public abstract class AbstractCommunicationManager implements Serializable {
StringWriter sWriter = new StringWriter();
PrintWriter pWriter = new PrintWriter(sWriter);
pWriter.print("{");
if (isXSRFEnabled(uI.getApplication())) {
if (isXSRFEnabled(uI.getSession())) {
pWriter.print(getSecurityKeyUIDL(request));
}
writeUidlResponse(request, true, pWriter, uI, false);

+ 1
- 1
server/src/com/vaadin/server/CommunicationManager.java View File

@@ -112,7 +112,7 @@ public class CommunicationManager extends AbstractCommunicationManager {
protected InputStream getThemeResourceAsStream(UI uI, String themeName,
String resource) {
VaadinServletSession context = (VaadinServletSession) uI
.getApplication();
.getSession();
ServletContext servletContext = context.getHttpSession()
.getServletContext();
return servletContext.getResourceAsStream("/"

+ 1
- 1
server/src/com/vaadin/server/ConnectorResourceHandler.java View File

@@ -44,7 +44,7 @@ public class ConnectorResourceHandler implements RequestHandler {
}

UI.setCurrent(ui);
VaadinSession.setCurrent(ui.getApplication());
VaadinSession.setCurrent(ui.getSession());

ClientConnector connector = ui.getConnectorTracker().getConnector(
cid);

+ 1
- 1
server/src/com/vaadin/server/JsonPaintTarget.java View File

@@ -345,7 +345,7 @@ public class JsonPaintTarget implements PaintTarget {
throw new NullPointerException();
}
ClientConnector ownerConnector = openPaintables.peek();
ownerConnector.getUI().getApplication().getGlobalResourceHandler(true)
ownerConnector.getUI().getSession().getGlobalResourceHandler(true)
.register(value, ownerConnector);

ResourceReference reference = ResourceReference.create(value,

+ 1
- 1
server/src/com/vaadin/server/Page.java View File

@@ -391,7 +391,7 @@ public class Page implements Serializable {
}

public WebBrowser getWebBrowser() {
return uI.getApplication().getBrowser();
return uI.getSession().getBrowser();
}

public void setBrowserWindowSize(int width, int height) {

+ 1
- 1
server/src/com/vaadin/server/PortletCommunicationManager.java View File

@@ -157,7 +157,7 @@ public class PortletCommunicationManager extends AbstractCommunicationManager {
protected InputStream getThemeResourceAsStream(UI uI, String themeName,
String resource) {
VaadinPortletSession context = (VaadinPortletSession) uI
.getApplication();
.getSession();
PortletContext portletContext = context.getPortletSession()
.getPortletContext();
return portletContext.getResourceAsStream("/"

+ 1
- 1
server/src/com/vaadin/server/ResourceReference.java View File

@@ -71,7 +71,7 @@ public class ResourceReference extends URLReference {
ConnectorResource connectorResource = (ConnectorResource) resource;

GlobalResourceHandler globalResourceHandler = connector.getUI()
.getApplication().getGlobalResourceHandler(false);
.getSession().getGlobalResourceHandler(false);
if (globalResourceHandler != null) {
String uri = globalResourceHandler.getUri(connector,
connectorResource);

+ 2
- 2
server/src/com/vaadin/server/VaadinSession.java View File

@@ -1706,8 +1706,8 @@ public class VaadinSession implements Terminal.ErrorListener,
UI ui = createUIInstance(request, uiClass);

// Initialize some fields for a newly created UI
if (ui.getApplication() == null) {
ui.setApplication(this);
if (ui.getSession() == null) {
ui.setSession(this);
}
// Get the next id
Integer uiId = Integer.valueOf(nextUIId++);

+ 2
- 27
server/src/com/vaadin/ui/AbstractComponent.java View File

@@ -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;
@@ -626,31 +626,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.
*

+ 1
- 1
server/src/com/vaadin/ui/AbstractField.java View File

@@ -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);
}


+ 1
- 24
server/src/com/vaadin/ui/Component.java View File

@@ -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;

/**
@@ -521,35 +520,13 @@ public interface Component extends ClientConnector, Sizeable, Serializable {
@Override
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:

+ 1
- 1
server/src/com/vaadin/ui/ConnectorTracker.java View File

@@ -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) {

+ 1
- 1
server/src/com/vaadin/ui/Label.java View File

@@ -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;

+ 3
- 3
server/src/com/vaadin/ui/LoginForm.java View File

@@ -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();
}

+ 1
- 1
server/src/com/vaadin/ui/Table.java View File

@@ -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) {

+ 36
- 17
server/src/com/vaadin/ui/UI.java View File

@@ -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);

+ 2
- 2
server/tests/src/com/vaadin/tests/data/converter/ConverterFactory.java View File

@@ -72,7 +72,7 @@ public class ConverterFactory extends TestCase {

TextField tf = new TextField("", "123") {
@Override
public VaadinSession getApplication() {
public VaadinSession getSession() {
return appWithCustomIntegerConverter;
};
};
@@ -103,7 +103,7 @@ public class ConverterFactory extends TestCase {

TextField tf = new TextField("", "123") {
@Override
public VaadinSession getApplication() {
public VaadinSession getSession() {
return fieldAppWithCustomIntegerConverter;
}
};

+ 1
- 1
server/tests/src/com/vaadin/tests/server/TestStreamVariableMapping.java View File

@@ -30,7 +30,7 @@ public class TestStreamVariableMapping extends TestCase {
}

@Override
public VaadinSession getApplication() {
public VaadinSession getSession() {
return application;
}
};

+ 1
- 1
server/tests/src/com/vaadin/tests/server/component/abstractfield/AbstractFieldValueConversions.java View File

@@ -190,7 +190,7 @@ public class AbstractFieldValueConversions extends TestCase {
VaadinSession.setCurrent(a);
TextField tf = new TextField() {
@Override
public VaadinSession getApplication() {
public VaadinSession getSession() {
return a;
}
};

+ 2
- 2
server/tests/src/com/vaadin/tests/server/component/abstractfield/RemoveListenersOnDetach.java View File

@@ -29,7 +29,7 @@ public class RemoveListenersOnDetach {
}

@Override
public VaadinSession getApplication() {
public VaadinSession getSession() {
return application;
}

@@ -59,7 +59,7 @@ public class RemoveListenersOnDetach {
};

@Override
public VaadinSession getApplication() {
public VaadinSession getSession() {
return application;
};
};

+ 31
- 16
server/tests/src/com/vaadin/tests/server/component/window/AttachDetachWindow.java View File

@@ -5,6 +5,7 @@ import static org.junit.Assert.assertTrue;

import org.junit.Test;

import com.vaadin.server.ClientConnector;
import com.vaadin.server.VaadinSession;
import com.vaadin.server.WrappedRequest;
import com.vaadin.ui.Label;
@@ -23,7 +24,7 @@ public class AttachDetachWindow {

public TestContent getTestContent();

public VaadinSession getApplication();
public VaadinSession getSession();
}

private class TestWindow extends Window implements TestContainer {
@@ -61,6 +62,11 @@ public class AttachDetachWindow {
public TestContent getTestContent() {
return testContent;
}

@Override
public VaadinSession getSession() {
return super.getSession();
}
}

private class TestContent extends VerticalLayout {
@@ -155,7 +161,7 @@ public class AttachDetachWindow {
assertUnattached(sub);

// attaching main should recurse to sub
main.setApplication(testApp);
main.setSession(testApp);
assertAttached(main);
assertAttached(sub);
}
@@ -165,7 +171,7 @@ public class AttachDetachWindow {
assertUnattached(main);
assertUnattached(sub);

main.setApplication(testApp);
main.setSession(testApp);
assertAttached(main);
assertUnattached(sub);

@@ -177,7 +183,7 @@ public class AttachDetachWindow {

@Test
public void removeSubWindowBeforeDetachingMainWindow() {
main.setApplication(testApp);
main.setSession(testApp);
main.addWindow(sub);

// sub should be detached when removing from attached main
@@ -186,18 +192,18 @@ public class AttachDetachWindow {
assertDetached(sub);

// main detach should recurse to sub
main.setApplication(null);
main.setSession(null);
assertDetached(main);
assertDetached(sub);
}

@Test
public void removeSubWindowAfterDetachingMainWindow() {
main.setApplication(testApp);
main.setSession(testApp);
main.addWindow(sub);

// main detach should recurse to sub
main.setApplication(null);
main.setSession(null);
assertDetached(main);
assertDetached(sub);

@@ -219,22 +225,31 @@ public class AttachDetachWindow {
assertTrue("window child attach not called",
testContent.childAttachCalled);

assertSame("window not attached", win.getApplication(), testApp);
assertSame("window content not attached", testContent.getApplication(),
testApp);
assertSame("window children not attached",
testContent.child.getApplication(), testApp);
assertSame("window not attached", win.getSession(), testApp);
assertSame("window content not attached", testContent.getUI()
.getSession(), testApp);
assertSame("window children not attached", testContent.child.getUI()
.getSession(), testApp);
}

/**
* Asserts that win and its children are not attached.
*/
private void assertUnattached(TestContainer win) {
assertSame("window not detached", win.getApplication(), null);
assertSame("window content not detached", win.getTestContent()
.getApplication(), null);
assertSame("window not detached", win.getSession(), null);
assertSame("window content not detached",
getVaadinSession(win.getTestContent()), null);
assertSame("window children not detached",
win.getTestContent().child.getApplication(), null);
getVaadinSession(win.getTestContent().child), null);
}

private VaadinSession getVaadinSession(ClientConnector testContainer) {
UI ui = testContainer.getUI();
if (ui != null) {
return ui.getSession();
} else {
return null;
}
}

/**

+ 1
- 1
uitest/src/com/vaadin/tests/StressComponentsInTable.java View File

@@ -54,7 +54,7 @@ public class StressComponentsInTable extends CustomComponent {
Button b = event.getButton();
System.out.println(b.getCaption() + " click: "
+ (new Date()).toString());
System.out.println(b.getApplication());
System.out.println(b.getUI().getSession());

}
}));

+ 1
- 1
uitest/src/com/vaadin/tests/TestForUpload.java View File

@@ -244,7 +244,7 @@ public class TestForUpload extends CustomComponent implements

@Override
public void buttonClick(ClickEvent event) {
getApplication().close();
getSession().close();
}
});
main.addComponent(restart);

+ 1
- 1
uitest/src/com/vaadin/tests/application/ApplicationCloseTest.java View File

@@ -26,7 +26,7 @@ public class ApplicationCloseTest extends TestBase {

@Override
public void buttonClick(ClickEvent event) {
event.getButton().getApplication().close();
event.getButton().getUI().getSession().close();
}
});


+ 1
- 1
uitest/src/com/vaadin/tests/components/AbstractTestUI.java View File

@@ -54,7 +54,7 @@ public abstract class AbstractTestUI extends UI {
protected abstract Integer getTicketNumber();

protected WebBrowser getBrowser() {
return getApplication().getBrowser();
return getSession().getBrowser();
}

}

+ 2
- 2
uitest/src/com/vaadin/tests/components/table/TableFirstRowFlicker.java View File

@@ -5,8 +5,8 @@ import com.vaadin.data.Container;
import com.vaadin.data.util.IndexedContainer;
import com.vaadin.ui.Label;
import com.vaadin.ui.ProgressIndicator;
import com.vaadin.ui.UI.LegacyWindow;
import com.vaadin.ui.Table;
import com.vaadin.ui.UI.LegacyWindow;
import com.vaadin.ui.VerticalLayout;

public class TableFirstRowFlicker extends LegacyApplication {
@@ -43,7 +43,7 @@ public class TableFirstRowFlicker extends LegacyApplication {
@Override
public void run() {
while (t != null) {
synchronized (t.getApplication()) {
synchronized (t.getUI().getSession()) {
int firstId = t.getCurrentPageFirstItemIndex();
Object selected = t.getValue();
t.setContainerDataSource(buildContainer());

+ 2
- 1
uitest/src/com/vaadin/tests/components/textfield/SelectionAndCursorPosition.java View File

@@ -30,7 +30,8 @@ public class SelectionAndCursorPosition extends TestBase {
ml.addListener(new Property.ValueChangeListener() {
@Override
public void valueChange(ValueChangeEvent event) {
if (textField.getApplication() == null) {
if (textField.getUI() == null
|| textField.getUI().getSession() == null) {
replaceComponent(textArea, textField);
activeComponent = textField;
} else {

+ 1
- 1
uitest/src/com/vaadin/tests/layouts/ComplexGLColumnExpansionWithColSpan.java View File

@@ -73,7 +73,7 @@ public class ComplexGLColumnExpansionWithColSpan extends AbstractTestCase {
restart.addListener(new Button.ClickListener() {
@Override
public void buttonClick(Button.ClickEvent event) {
mainLayout.getUI().getApplication().close();
mainLayout.getUI().getSession().close();
}
});


+ 1
- 1
uitest/src/com/vaadin/tests/minitutorials/v7a1/CustomConverterFactoryUI.java View File

@@ -7,7 +7,7 @@ import com.vaadin.ui.TextField;
public class CustomConverterFactoryUI extends AbstractTestUI {
@Override
public void setup(WrappedRequest request) {
getApplication().setConverterFactory(new MyConverterFactory());
getSession().setConverterFactory(new MyConverterFactory());

TextField tf = new TextField("This is my double field");
tf.setImmediate(true);

+ 2
- 2
uitest/src/com/vaadin/tests/minitutorials/v7a1/DynamicImageUI.java View File

@@ -20,12 +20,12 @@ public class DynamicImageUI extends AbstractTestUI {
@Override
public void setup(WrappedRequest request) {
// Add the request handler that handles our dynamic image
getApplication().addRequestHandler(new DynamicImageRequestHandler());
getSession().addRequestHandler(new DynamicImageRequestHandler());

// Create a URL that we can handle in DynamicImageRequestHandler
URL imageUrl;
try {
imageUrl = new URL(getApplication().getURL(),
imageUrl = new URL(getSession().getURL(),
DynamicImageRequestHandler.IMAGE_URL + "?text=Hello!");
} catch (MalformedURLException e) {
// This should never happen

Loading…
Cancel
Save