01: package org.apache.struts.wrapper;
02:
03: import java.io.IOException;
04: import java.io.PrintWriter;
05: import java.io.OutputStream;
06:
07: import javax.servlet.ServletOutputStream;
08: import javax.servlet.http.HttpServletResponse;
09: import javax.servlet.http.HttpServletResponseWrapper;
10:
11: import javax.portlet.PortletRequest;
12: import javax.portlet.PortletResponse;
13: import javax.portlet.ActionResponse;
14: import javax.portlet.RenderResponse;
15:
16: public class StrutsServletResponse extends HttpServletResponseWrapper {
17:
18: private ActionResponse _aRes;
19: private RenderResponse _rRes;
20:
21: private StrutsServletOutputStream _outputStream;
22:
23: public StrutsServletResponse(HttpServletResponse sRes,
24: PortletRequest req, ActionResponse res) {
25: super (sRes);
26: _aRes = res;
27: req.setAttribute("javax.portlet.response", res);
28: }
29:
30: public StrutsServletResponse(HttpServletResponse sRes,
31: PortletRequest req, RenderResponse res) {
32: super (sRes);
33: _rRes = res;
34: req.setAttribute("javax.portlet.response", res);
35: }
36:
37: public java.io.PrintWriter getWriter() throws java.io.IOException {
38: if (_rRes != null) {
39: return _rRes.getWriter();
40: } else {
41: return null;
42: }
43: }
44:
45: public ServletOutputStream getOutputStream()
46: throws java.io.IOException {
47: if (_rRes != null) {
48: if (_outputStream == null) {
49: _outputStream = new StrutsServletOutputStream(_rRes
50: .getPortletOutputStream());
51: }
52: return _outputStream;
53: } else {
54: return null;
55: }
56: }
57:
58: public String encodeURL(String path) {
59: return _rRes.encodeURL(path);
60: }
61:
62: public void sendRedirect(String location) throws IOException {
63: // disable for portlet
64: }
65:
66: }
|