summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeif Åstrand <leif@vaadin.com>2012-07-24 13:47:56 +0300
committerLeif Åstrand <leif@vaadin.com>2012-07-24 13:47:56 +0300
commit0c093be6af6c9ea16a8fb446646a6fec08562d60 (patch)
tree635a297199b680b1d6560274f704bb53c7e866f5
parent410653ce8608da1be105fc3e814799f6fe1c2163 (diff)
downloadvaadin-framework-0c093be6af6c9ea16a8fb446646a6fec08562d60.tar.gz
vaadin-framework-0c093be6af6c9ea16a8fb446646a6fec08562d60.zip
Restore portlet application to reduce problems with event ordering
This reverts commit 8725ab419ad084ff5d04987406054333947d3232
-rw-r--r--tests/testbench/com/vaadin/tests/integration/JSR286PortletApplication.java (renamed from tests/testbench/com/vaadin/tests/integration/JSR286PortletRoot.java)49
1 files changed, 20 insertions, 29 deletions
diff --git a/tests/testbench/com/vaadin/tests/integration/JSR286PortletRoot.java b/tests/testbench/com/vaadin/tests/integration/JSR286PortletApplication.java
index e77557537c..7ba6f2c0c0 100644
--- a/tests/testbench/com/vaadin/tests/integration/JSR286PortletRoot.java
+++ b/tests/testbench/com/vaadin/tests/integration/JSR286PortletApplication.java
@@ -18,17 +18,17 @@ import javax.portlet.ResourceRequest;
import javax.portlet.ResourceResponse;
import javax.portlet.WindowState;
+import com.vaadin.Application;
import com.vaadin.terminal.ExternalResource;
-import com.vaadin.terminal.WrappedRequest;
import com.vaadin.terminal.gwt.client.ui.label.ContentMode;
import com.vaadin.terminal.gwt.server.PortletApplicationContext2;
import com.vaadin.terminal.gwt.server.PortletApplicationContext2.PortletListener;
-import com.vaadin.ui.ComponentContainer;
import com.vaadin.ui.Embedded;
import com.vaadin.ui.Label;
import com.vaadin.ui.Link;
import com.vaadin.ui.Notification;
import com.vaadin.ui.Root;
+import com.vaadin.ui.Root.LegacyWindow;
import com.vaadin.ui.TextField;
import com.vaadin.ui.Upload;
import com.vaadin.ui.Upload.Receiver;
@@ -36,8 +36,9 @@ import com.vaadin.ui.Upload.Receiver;
/**
* Adapted from old PortletDemo to support integration testing.
*/
-public class JSR286PortletRoot extends Root {
+public class JSR286PortletApplication extends Application.LegacyApplication {
+ LegacyWindow main = new LegacyWindow();
TextField tf = new TextField("Some value");
Label userInfo = new Label();
Link portletEdit = new Link();
@@ -45,19 +46,16 @@ public class JSR286PortletRoot extends Root {
Link someAction = null;
@Override
- protected void init(WrappedRequest request) {
- ComponentContainer main = getContent();
- tf.setDebugId("tf");
- userInfo.setDebugId("userInfo");
- portletEdit.setDebugId("portletEdit");
- portletMax.setDebugId("portletMax");
+ public void init() {
+ setMainWindow(main);
+
Embedded appResourceTest = new Embedded(
"Test of ApplicationResources with full path",
- new FlagSeResource(getApplication()));
+ new FlagSeResource(this));
main.addComponent(appResourceTest);
Embedded specialNameResourceTest = new Embedded(
"Test ApplicationResources with special names",
- new SpecialNameResource(getApplication()));
+ new SpecialNameResource(this));
main.addComponent(specialNameResourceTest);
userInfo.setCaption("User info");
@@ -75,19 +73,17 @@ public class JSR286PortletRoot extends Root {
Upload upload = new Upload("Upload a file", new Receiver() {
- @Override
public OutputStream receiveUpload(String filename, String mimeType) {
return new ByteArrayOutputStream();
}
});
main.addComponent(upload);
- if (getApplication().getContext() instanceof PortletApplicationContext2) {
- PortletApplicationContext2 ctx = (PortletApplicationContext2) getApplication()
- .getContext();
- ctx.addPortletListener(getApplication(), new DemoPortletListener());
+ if (getContext() instanceof PortletApplicationContext2) {
+ PortletApplicationContext2 ctx = (PortletApplicationContext2) getContext();
+ ctx.addPortletListener(this, new DemoPortletListener());
} else {
- Notification.show("Not inited via Portal!",
+ getMainWindow().showNotification("Not inited via Portal!",
Notification.TYPE_ERROR_MESSAGE);
}
@@ -95,13 +91,11 @@ public class JSR286PortletRoot extends Root {
private class DemoPortletListener implements PortletListener {
- @Override
public void handleActionRequest(ActionRequest request,
ActionResponse response, Root window) {
- getContent().addComponent(new Label("Action received"));
+ main.addComponent(new Label("Action received"));
}
- @Override
public void handleRenderRequest(RenderRequest request,
RenderResponse response, Root window) {
// Portlet up-and-running, enable stuff
@@ -112,10 +106,11 @@ public class JSR286PortletRoot extends Root {
tf.setEnabled((request.getPortletMode() == PortletMode.EDIT));
// Show notification about current mode and state
- new Notification("Portlet status", "Mode: "
- + request.getPortletMode() + " State: "
- + request.getWindowState(),
- Notification.TYPE_WARNING_MESSAGE).show(getPage());
+ getMainWindow().showNotification(
+ "Portlet status",
+ "Mode: " + request.getPortletMode() + " State: "
+ + request.getWindowState(),
+ Notification.TYPE_WARNING_MESSAGE);
// Display current user info
Map<?, ?> uinfo = (Map<?, ?>) request
@@ -165,9 +160,7 @@ public class JSR286PortletRoot extends Root {
try {
someAction = new Link("An action", new ExternalResource(
url.toString()));
- someAction.setDebugId("someAction");
-
- addComponent(someAction);
+ main.addComponent(someAction);
} catch (Exception e) {
// Oops
System.err.println("Could not create someAction: " + e);
@@ -176,13 +169,11 @@ public class JSR286PortletRoot extends Root {
}
}
- @Override
public void handleEventRequest(EventRequest request,
EventResponse response, Root window) {
// events not used by this test
}
- @Override
public void handleResourceRequest(ResourceRequest request,
ResourceResponse response, Root window) {
// nothing special to do here