]> source.dussan.org Git - vaadin-framework.git/commitdiff
Allow creation of stream variables in RenderRequests aswell (#8785)
authorArtur Signell <artur@vaadin.com>
Fri, 11 May 2012 16:47:22 +0000 (19:47 +0300)
committerArtur Signell <artur@vaadin.com>
Sun, 13 May 2012 17:35:32 +0000 (20:35 +0300)
src/com/vaadin/terminal/gwt/server/PortletCommunicationManager.java

index b3ec33a9e0f633ed2cfebeca8b7d450e8a125c0d..1e2687982e427e88feda857c82c9947ae186d60c 100644 (file)
@@ -38,7 +38,7 @@ import com.vaadin.ui.Root;
 @SuppressWarnings("serial")
 public class PortletCommunicationManager extends AbstractCommunicationManager {
 
-    private transient ResourceResponse currentUidlResponse;
+    private transient MimeResponse currentMimeResponse;
 
     public PortletCommunicationManager(Application application) {
         super(application);
@@ -82,14 +82,26 @@ public class PortletCommunicationManager extends AbstractCommunicationManager {
         }
     }
 
+    @Override
+    protected boolean handleApplicationRequest(WrappedRequest request,
+            WrappedResponse response) throws IOException {
+        currentMimeResponse = (RenderResponse) ((WrappedPortletResponse) response)
+                .getPortletResponse();
+        try {
+            return super.handleApplicationRequest(request, response);
+        } finally {
+            currentMimeResponse = null;
+        }
+    }
+
     @Override
     public void handleUidlRequest(WrappedRequest request,
             WrappedResponse response, Callback callback, Root root)
             throws IOException, InvalidUIDLSecurityKeyException {
-        currentUidlResponse = (ResourceResponse) ((WrappedPortletResponse) response)
+        currentMimeResponse = (ResourceResponse) ((WrappedPortletResponse) response)
                 .getPortletResponse();
         super.handleUidlRequest(request, response, callback, root);
-        currentUidlResponse = null;
+        currentMimeResponse = null;
     }
 
     private Map<Connector, Map<String, StreamVariable>> ownerToNameToStreamVariable;
@@ -107,7 +119,7 @@ public class PortletCommunicationManager extends AbstractCommunicationManager {
             ownerToNameToStreamVariable.put(owner, nameToReceiver);
         }
         nameToReceiver.put(name, value);
-        ResourceURL resurl = currentUidlResponse.createResourceURL();
+        ResourceURL resurl = createResourceURL();
         resurl.setResourceID("UPLOAD");
         resurl.setParameter("name", name);
         resurl.setParameter("rec-owner", owner.getConnectorId());
@@ -116,6 +128,14 @@ public class PortletCommunicationManager extends AbstractCommunicationManager {
         return resurl.toString();
     }
 
+    private ResourceURL createResourceURL() {
+        if (currentMimeResponse == null) {
+            throw new RuntimeException(
+                    "No reponse object available. Cannot create a resource URL");
+        }
+        return currentMimeResponse.createResourceURL();
+    }
+
     @Override
     protected void cleanStreamVariable(Connector owner, String name) {
         Map<String, StreamVariable> map = ownerToNameToStreamVariable