throws IOException {
String requestPathInfo = request.getRequestPathInfo();
if ("/loginHandler".equals(requestPathInfo)) {
+ // Ensure Root.getCurrent() works in listeners
+ Root.setCurrent(getRoot());
+
response.setCacheTime(-1);
response.setContentType("text/html; charset=utf-8");
response.getWriter()
--- /dev/null
+package com.vaadin.tests.components.loginform;\r
+\r
+import com.vaadin.tests.components.TestBase;\r
+import com.vaadin.ui.Label;\r
+import com.vaadin.ui.LoginForm;\r
+import com.vaadin.ui.LoginForm.LoginEvent;\r
+import com.vaadin.ui.LoginForm.LoginListener;\r
+import com.vaadin.ui.Root;\r
+\r
+public class LoginFormRootInLoginHandler extends TestBase {\r
+\r
+ @Override\r
+ protected void setup() {\r
+ LoginForm lf = new LoginForm();\r
+ lf.addListener(new LoginListener() {\r
+\r
+ @Override\r
+ public void onLogin(LoginEvent event) {\r
+ Root r1 = Root.getCurrent();\r
+ if (r1 != null) {\r
+ addComponent(new Label("Root.getCurrent().data: "\r
+ + r1.getData()));\r
+ } else {\r
+ addComponent(new Label("Root.getCurrent() is null"));\r
+ }\r
+ Root r2 = ((LoginForm) event.getSource()).getRoot();\r
+ if (r2 != null) {\r
+ addComponent(new Label("event.getSource().data: "\r
+ + r2.getData()));\r
+ } else {\r
+ addComponent(new Label(\r
+ "event.getSource().getRoot() is null"));\r
+ }\r
+ }\r
+ });\r
+ addComponent(lf);\r
+ getLayout().getRoot().setData("This root");\r
+ }\r
+\r
+ @Override\r
+ protected String getDescription() {\r
+ // TODO Auto-generated method stub\r
+ return null;\r
+ }\r
+\r
+ @Override\r
+ protected Integer getTicketNumber() {\r
+ // TODO Auto-generated method stub\r
+ return null;\r
+ }\r
+\r
+}\r