@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
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;
@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;