summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--server/src/com/vaadin/server/VaadinService.java25
-rw-r--r--server/src/com/vaadin/server/VaadinSession.java11
-rw-r--r--server/src/com/vaadin/ui/AbstractComponent.java9
-rw-r--r--server/src/com/vaadin/ui/AbstractComponentContainer.java13
-rw-r--r--server/src/com/vaadin/ui/AbstractSingleComponentContainer.java13
-rw-r--r--server/src/com/vaadin/ui/Form.java13
-rw-r--r--theme-compiler/ivy.xml3
-rw-r--r--uitest/src/com/vaadin/tests/applicationcontext/CloseSession.html69
-rw-r--r--uitest/src/com/vaadin/tests/applicationcontext/CloseSession.java59
-rw-r--r--uitest/src/com/vaadin/tests/components/customcomponent/CustomComponentChildVisibility.html47
-rw-r--r--uitest/src/com/vaadin/tests/components/customcomponent/CustomComponentChildVisibility.java60
11 files changed, 270 insertions, 52 deletions
diff --git a/server/src/com/vaadin/server/VaadinService.java b/server/src/com/vaadin/server/VaadinService.java
index 5d3f79fddb..5338ec217b 100644
--- a/server/src/com/vaadin/server/VaadinService.java
+++ b/server/src/com/vaadin/server/VaadinService.java
@@ -789,12 +789,27 @@ public abstract class VaadinService implements Serializable {
removeClosedUIs(session);
} else {
if (!session.isClosing()) {
- getLogger().fine(
- "Closing inactive session "
- + session.getSession().getId());
closeSession(session);
+ if (session.getSession() != null) {
+ getLogger().fine(
+ "Closing inactive session "
+ + session.getSession().getId());
+ }
+ }
+ if (session.getSession() != null) {
+ /*
+ * If the VaadinSession has no WrappedSession then it has
+ * already been removed from the HttpSession and we do not have
+ * to do it again
+ */
+ session.removeFromSession(this);
}
- session.removeFromSession(this);
+
+ /*
+ * The session was destroyed during this request and therefore no
+ * destroy event has yet been sent
+ */
+ fireSessionDestroy(session);
}
}
@@ -914,7 +929,7 @@ public abstract class VaadinService implements Serializable {
* @return true if the session is active, false if it could be closed.
*/
private boolean isSessionActive(VaadinSession session) {
- if (session.isClosing()) {
+ if (session.isClosing() || session.getSession() == null) {
return false;
} else {
long now = System.currentTimeMillis();
diff --git a/server/src/com/vaadin/server/VaadinSession.java b/server/src/com/vaadin/server/VaadinSession.java
index 205e4dc6cf..4aa2ef5d92 100644
--- a/server/src/com/vaadin/server/VaadinSession.java
+++ b/server/src/com/vaadin/server/VaadinSession.java
@@ -160,7 +160,18 @@ public class VaadinSession implements HttpSessionBindingListener, Serializable {
"A VaadinSession instance not associated to any service is getting unbound. "
+ "Session destroy events will not be fired and UIs in the session will not get detached. "
+ "This might happen if a session is deserialized but never used before it expires.");
+ } else if (VaadinService.getCurrentRequest() != null
+ && getCurrent() == this) {
+ // There is still a request in progress for this session. The
+ // session will be destroyed after the response has been written.
+ if (!isClosing()) {
+ close();
+ }
} else {
+ /*
+ * We are not in a request related to this session so we can
+ * immediately destroy it
+ */
service.fireSessionDestroy(this);
}
session = null;
diff --git a/server/src/com/vaadin/ui/AbstractComponent.java b/server/src/com/vaadin/ui/AbstractComponent.java
index 876a6c482d..63cf19283f 100644
--- a/server/src/com/vaadin/ui/AbstractComponent.java
+++ b/server/src/com/vaadin/ui/AbstractComponent.java
@@ -401,7 +401,14 @@ public abstract class AbstractComponent extends AbstractClientConnector
}
this.visible = visible;
- markAsDirty();
+ if (visible) {
+ /*
+ * If the visibility state is toggled from invisible to visible it
+ * affects all children (the whole hierarchy) in addition to this
+ * component.
+ */
+ markAsDirtyRecursive();
+ }
if (getParent() != null) {
// Must always repaint the parent (at least the hierarchy) when
// visibility of a child component changes.
diff --git a/server/src/com/vaadin/ui/AbstractComponentContainer.java b/server/src/com/vaadin/ui/AbstractComponentContainer.java
index 427bb3491c..4dd8a8d24a 100644
--- a/server/src/com/vaadin/ui/AbstractComponentContainer.java
+++ b/server/src/com/vaadin/ui/AbstractComponentContainer.java
@@ -232,19 +232,6 @@ public abstract class AbstractComponentContainer extends AbstractComponent
}
@Override
- public void setVisible(boolean visible) {
- if (isVisible() == visible) {
- return;
- }
-
- super.setVisible(visible);
- // If the visibility state is toggled it might affect all children
- // as well, e.g. make container visible should make children visible if
- // they were only hidden because the container was hidden.
- markAsDirtyRecursive();
- }
-
- @Override
public void setWidth(float width, Unit unit) {
/*
* child tree repaints may be needed, due to our fall back support for
diff --git a/server/src/com/vaadin/ui/AbstractSingleComponentContainer.java b/server/src/com/vaadin/ui/AbstractSingleComponentContainer.java
index 7297318e95..5ff56d46dc 100644
--- a/server/src/com/vaadin/ui/AbstractSingleComponentContainer.java
+++ b/server/src/com/vaadin/ui/AbstractSingleComponentContainer.java
@@ -103,19 +103,6 @@ public abstract class AbstractSingleComponentContainer extends
}
@Override
- public void setVisible(boolean visible) {
- if (isVisible() == visible) {
- return;
- }
-
- super.setVisible(visible);
- // If the visibility state is toggled it might affect all children
- // aswell, e.g. make container visible should make children visible if
- // they were only hidden because the container was hidden.
- markAsDirtyRecursive();
- }
-
- @Override
public Component getContent() {
return content;
}
diff --git a/server/src/com/vaadin/ui/Form.java b/server/src/com/vaadin/ui/Form.java
index 68ebb079f9..862d98bb3c 100644
--- a/server/src/com/vaadin/ui/Form.java
+++ b/server/src/com/vaadin/ui/Form.java
@@ -1374,17 +1374,4 @@ public class Form extends AbstractField<Object> implements Item.Editor,
return count;
}
- @Override
- public void setVisible(boolean visible) {
- if (isVisible() == visible) {
- return;
- }
-
- super.setVisible(visible);
- // If the visibility state is toggled it might affect all children
- // aswell, e.g. make container visible should make children visible if
- // they were only hidden because the container was hidden.
- markAsDirtyRecursive();
- }
-
}
diff --git a/theme-compiler/ivy.xml b/theme-compiler/ivy.xml
index 9423512d50..53cbc550c1 100644
--- a/theme-compiler/ivy.xml
+++ b/theme-compiler/ivy.xml
@@ -35,9 +35,6 @@
<dependency org="commons-cli" name="commons-cli" rev="1.2"
conf="build,ide,tests->default" />
- <dependency org="com.vaadin" name="vaadin-shared-deps" rev="1.0.0"
- conf="build,ide,tests->default" />
-
<!-- Provided build libs -->
<dependency org="javax.servlet" name="servlet-api"
rev="2.4" conf="build-provided->default" />
diff --git a/uitest/src/com/vaadin/tests/applicationcontext/CloseSession.html b/uitest/src/com/vaadin/tests/applicationcontext/CloseSession.html
index 99cfededb1..eb6e7681e6 100644
--- a/uitest/src/com/vaadin/tests/applicationcontext/CloseSession.html
+++ b/uitest/src/com/vaadin/tests/applicationcontext/CloseSession.html
@@ -40,7 +40,7 @@
</tr>
<tr>
<td>clickAndWait</td>
- <td>vaadin=runcomvaadintestsapplicationcontextCloseSession::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[4]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td>vaadin=runcomvaadintestsapplicationcontextCloseSession::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[5]/VButton[0]/domChild[0]/domChild[0]</td>
<td></td>
</tr>
<tr>
@@ -53,7 +53,7 @@
<td>vaadin=runcomvaadintestsapplicationcontextCloseSession::PID_SLog_row_0</td>
<td>exact:6. Same WrappedSession id? false</td>
</tr>
-<!--Test closing session and redirecting to google-->
+<!--Test closing session and redirecting to another page-->
<tr>
<td>clickAndWait</td>
<td>vaadin=runcomvaadintestsapplicationcontextCloseSession::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VButton[0]/domChild[0]/domChild[0]</td>
@@ -64,7 +64,7 @@
<td>//h1</td>
<td>This is a static file</td>
</tr>
-<!--Open again and verify we get a Session Expired error if doing something after closing the session-->
+<!--Open again and verify we get a Session Expired error if doing something after closing the VaadinSession-->
<tr>
<td>open</td>
<td>/run/com.vaadin.tests.applicationcontext.CloseSession?restartApplication</td>
@@ -85,6 +85,69 @@
<td>vaadin=runcomvaadintestsapplicationcontextCloseSession::Root/VNotification[0]/HTML[0]/domChild[0]</td>
<td>Session Expired</td>
</tr>
+<!--Open again and verify we get a Session Expired error if doing something after closing the HttpSession-->
+<tr>
+ <td>open</td>
+ <td>/run/com.vaadin.tests.applicationcontext.CloseSession?restartApplication</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runcomvaadintestsapplicationcontextCloseSession::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[4]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runcomvaadintestsapplicationcontextCloseSession::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[4]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestsapplicationcontextCloseSession::Root/VNotification[0]/HTML[0]/domChild[0]</td>
+ <td>Session Expired</td>
+</tr>
+<!--Open again and verify we get a Session Expired error if closing HttpSession in a background thread-->
+<tr>
+ <td>open</td>
+ <td>/run/com.vaadin.tests.applicationcontext.CloseSession?restartApplication</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runcomvaadintestsapplicationcontextCloseSession::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[7]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>pause</td>
+ <td>2000</td>
+ <td>2000</td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runcomvaadintestsapplicationcontextCloseSession::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[7]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestsapplicationcontextCloseSession::Root/VNotification[0]/HTML[0]/domChild[0]</td>
+ <td>Session Expired</td>
+</tr>
+<!--Open again and test closing session and redirecting to another page-->
+<tr>
+ <td>open</td>
+ <td>/run/com.vaadin.tests.applicationcontext.CloseSession?restartApplication</td>
+ <td></td>
+</tr>
+<tr>
+ <td>clickAndWait</td>
+ <td>vaadin=runcomvaadintestsapplicationcontextCloseSession::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>//h1</td>
+ <td>This is a static file</td>
+</tr>
</tbody></table>
</body>
</html>
diff --git a/uitest/src/com/vaadin/tests/applicationcontext/CloseSession.java b/uitest/src/com/vaadin/tests/applicationcontext/CloseSession.java
index 41cbd42e94..446638f8a2 100644
--- a/uitest/src/com/vaadin/tests/applicationcontext/CloseSession.java
+++ b/uitest/src/com/vaadin/tests/applicationcontext/CloseSession.java
@@ -16,8 +16,11 @@
package com.vaadin.tests.applicationcontext;
+import javax.servlet.http.HttpSession;
+
import com.vaadin.server.VaadinRequest;
import com.vaadin.server.VaadinService;
+import com.vaadin.server.WrappedHttpSession;
import com.vaadin.tests.components.AbstractTestUI;
import com.vaadin.tests.util.Log;
import com.vaadin.ui.Button;
@@ -31,6 +34,8 @@ public class CloseSession extends AbstractTestUI {
@Override
protected void setup(VaadinRequest request) {
+ System.out.println("UI " + getUIId() + " inited");
+
final int sessionHash = getSession().hashCode();
final String sessionId = request.getWrappedSession().getId();
@@ -75,20 +80,67 @@ public class CloseSession extends AbstractTestUI {
getSession().close();
}
}));
- addComponent(new Button("Just close session",
+ addComponent(new Button("Just close VaadinSession",
new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
getSession().close();
}
}));
+ addComponent(new Button("Just close HttpSession",
+ new Button.ClickListener() {
+ @Override
+ public void buttonClick(ClickEvent event) {
+ getSession().getSession().invalidate();
+ }
+ }));
addComponent(new Button("Invalidate HttpSession and reopen page",
new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
+ VaadinService.getCurrentRequest().getWrappedSession()
+ .invalidate();
getPage().setLocation(reopenUrl);
+ }
+ }));
+ addComponent(new Button(
+ "Invalidate HttpSession and redirect elsewhere",
+ new Button.ClickListener() {
+ @Override
+ public void buttonClick(ClickEvent event) {
VaadinService.getCurrentRequest().getWrappedSession()
.invalidate();
+ getPage().setLocation("/statictestfiles/static.html");
+ }
+ }));
+ addComponent(new Button(
+ "Invalidate HttpSession in a background thread",
+ new Button.ClickListener() {
+ @Override
+ public void buttonClick(ClickEvent event) {
+ final HttpSession session = ((WrappedHttpSession) VaadinService
+ .getCurrentRequest().getWrappedSession())
+ .getHttpSession();
+ Thread t = new Thread(new Runnable() {
+
+ @Override
+ public void run() {
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ System.out
+ .println("Invalidating session from thread "
+ + session.getId());
+ session.invalidate();
+ System.out
+ .println("Invalidated session from thread "
+ + session.getId());
+
+ }
+ });
+ t.start();
}
}));
}
@@ -103,4 +155,9 @@ public class CloseSession extends AbstractTestUI {
return Integer.valueOf(9859);
}
+ @Override
+ public void detach() {
+ super.detach();
+ System.out.println("UI " + getUIId() + " detached");
+ }
}
diff --git a/uitest/src/com/vaadin/tests/components/customcomponent/CustomComponentChildVisibility.html b/uitest/src/com/vaadin/tests/components/customcomponent/CustomComponentChildVisibility.html
new file mode 100644
index 0000000000..ac2f0452b3
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/customcomponent/CustomComponentChildVisibility.html
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head profile="http://selenium-ide.openqa.org/profiles/test-case">
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<link rel="selenium.base" href="http://arturwin.office.itmill.com:8888/" />
+<title>New Test</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="3">New Test</td></tr>
+</thead><tbody>
+<tr>
+ <td>open</td>
+ <td>/run/com.vaadin.tests.components.customcomponent.CustomComponentChildVisibility?debug&amp;restartApplication</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentscustomcomponentCustomComponentChildVisibility::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VCustomComponent[0]/VPanel[0]/VLabel[0]</td>
+ <td>In panel</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentscustomcomponentCustomComponentChildVisibility::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VCheckBox[0]/domChild[0]</td>
+ <td>7,7</td>
+</tr>
+<tr>
+ <td>assertElementNotPresent</td>
+ <td>vaadin=runcomvaadintestscomponentscustomcomponentCustomComponentChildVisibility::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VCustomComponent[0]/VPanel[0]/VLabel[0]</td>
+ <td>In panel</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentscustomcomponentCustomComponentChildVisibility::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VCheckBox[0]/domChild[0]</td>
+ <td>7,7</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentscustomcomponentCustomComponentChildVisibility::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VCustomComponent[0]/VPanel[0]/VLabel[0]</td>
+ <td>In panel</td>
+</tr>
+
+</tbody></table>
+</body>
+</html>
diff --git a/uitest/src/com/vaadin/tests/components/customcomponent/CustomComponentChildVisibility.java b/uitest/src/com/vaadin/tests/components/customcomponent/CustomComponentChildVisibility.java
new file mode 100644
index 0000000000..a9899b2815
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/customcomponent/CustomComponentChildVisibility.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2012 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.tests.components.customcomponent;
+
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.Property.ValueChangeListener;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.CheckBox;
+import com.vaadin.ui.CustomComponent;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Panel;
+
+public class CustomComponentChildVisibility extends AbstractTestUI {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ final CustomComponent cc = new CustomComponent(new Panel(
+ "In CustomComponent", new Label("In panel")));
+
+ final CheckBox cb = new CheckBox("CustomComponent visible");
+ cb.setValue(true);
+ cb.setImmediate(true);
+ cb.addValueChangeListener(new ValueChangeListener() {
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ cc.setVisible(cb.getValue());
+ }
+ });
+ addComponent(cc);
+ addComponent(cb);
+
+ }
+
+ @Override
+ protected String getTestDescription() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}