32
32
import javax .portlet .MimeResponse ;
33
33
import javax .portlet .PortletException ;
34
34
import javax .portlet .PortletRequest ;
35
+ import javax .portlet .PortletRequestDispatcher ;
35
36
import javax .portlet .PortletResponse ;
36
37
import javax .portlet .PortletSession ;
37
38
import javax .portlet .RenderRequest ;
@@ -1158,8 +1159,8 @@ protected View resolveViewName(String viewName, Map model, PortletRequest reques
1158
1159
* {@link org.springframework.web.servlet.ViewRendererServlet}.
1159
1160
* @param view the View to render
1160
1161
* @param model the associated model
1161
- * @param request current portlet render request
1162
- * @param response current portlet render response
1162
+ * @param request current portlet render/resource request
1163
+ * @param response current portlet render/resource response
1163
1164
* @throws Exception if there's a problem rendering the view
1164
1165
*/
1165
1166
protected void doRender (View view , Map model , PortletRequest request , MimeResponse response ) throws Exception {
@@ -1170,8 +1171,28 @@ protected void doRender(View view, Map model, PortletRequest request, MimeRespon
1170
1171
request .setAttribute (ViewRendererServlet .VIEW_ATTRIBUTE , view );
1171
1172
request .setAttribute (ViewRendererServlet .MODEL_ATTRIBUTE , model );
1172
1173
1173
- // Include the content of the view in the render response.
1174
- getPortletContext ().getRequestDispatcher (this .viewRendererUrl ).include (request , response );
1174
+ // Include the content of the view in the render/resource response.
1175
+ doDispatch (getPortletContext ().getRequestDispatcher (this .viewRendererUrl ), request , response );
1176
+ }
1177
+
1178
+ /**
1179
+ * Perform a dispatch on the given PortletRequestDispatcher.
1180
+ * <p>The default implementation uses a forward for resource requests
1181
+ * and an include for render requests.
1182
+ * @param dispatcher the PortletRequestDispatcher to use
1183
+ * @param request current portlet render/resource request
1184
+ * @param response current portlet render/resource response
1185
+ * @throws Exception if there's a problem performing the dispatch
1186
+ */
1187
+ protected void doDispatch (PortletRequestDispatcher dispatcher , PortletRequest request , MimeResponse response )
1188
+ throws Exception {
1189
+
1190
+ if (PortletRequest .RESOURCE_PHASE .equals (request .getAttribute (PortletRequest .LIFECYCLE_PHASE ))) {
1191
+ dispatcher .forward (request , response );
1192
+ }
1193
+ else {
1194
+ dispatcher .include (request , response );
1195
+ }
1175
1196
}
1176
1197
1177
1198
0 commit comments