]> source.dussan.org Git - vaadin-framework.git/commitdiff
Corrected fix and better error checking for action/event request (#12056)
authorArtur Signell <artur@vaadin.com>
Thu, 13 Jun 2013 15:31:59 +0000 (18:31 +0300)
committerArtur Signell <artur@vaadin.com>
Fri, 14 Jun 2013 06:15:12 +0000 (09:15 +0300)
Change-Id: I85e8fff753baba2d0c373f235ddf74d0d2a97ed3

server/src/com/vaadin/server/VaadinPortletResponse.java
server/src/com/vaadin/server/communication/PortletStateAwareRequestHandler.java

index 334b94a5dca649cd0e2d1845c9980bd772d5fab3..ccb35a2c911b69dd3c59b66b4052bdb976d9662a 100644 (file)
@@ -85,12 +85,23 @@ public class VaadinPortletResponse implements VaadinResponse {
 
     @Override
     public void setContentType(String type) {
-        ((MimeResponse) response).setContentType(type);
+        if (response instanceof MimeResponse) {
+            ((MimeResponse) response).setContentType(type);
+        } else {
+            throw new RuntimeException(
+                    "Content type cannot be set for response of type "
+                            + response.getClass().getName());
+        }
     }
 
     @Override
     public PrintWriter getWriter() throws IOException {
-        return ((MimeResponse) response).getWriter();
+        if (response instanceof MimeResponse) {
+            return ((MimeResponse) response).getWriter();
+        } else {
+            throw new IOException("Writer not available for response of type "
+                    + response.getClass().getName());
+        }
     }
 
     @Override
index 162c479facde1dea0ac8fad343c1544e866805f8..4072aae35935759df4b174ac1c678ca43ff86aec 100644 (file)
@@ -17,9 +17,11 @@ package com.vaadin.server.communication;
 
 import java.io.IOException;
 
+import javax.portlet.PortletResponse;
 import javax.portlet.StateAwareResponse;
 
 import com.vaadin.server.RequestHandler;
+import com.vaadin.server.VaadinPortletResponse;
 import com.vaadin.server.VaadinRequest;
 import com.vaadin.server.VaadinResponse;
 import com.vaadin.server.VaadinSession;
@@ -43,7 +45,12 @@ public class PortletStateAwareRequestHandler implements RequestHandler {
     @Override
     public boolean handleRequest(VaadinSession session, VaadinRequest request,
             VaadinResponse response) throws IOException {
-        if (response instanceof StateAwareResponse) {
+        if (!(response instanceof VaadinPortletResponse)) {
+            return false;
+        }
+        PortletResponse portletResponse = ((VaadinPortletResponse) response)
+                .getPortletResponse();
+        if (portletResponse instanceof StateAwareResponse) {
             // StateAwareResponse is fully handled by listeners through
             // PortletListenerNotifier
             return true;