WindowState windowState, PortletMode portletMode,
PortletPreferences prefs, String layoutId) {
_portletName = portlet.getPortletId();
DynamicServletRequest dynamicReq =
new DynamicServletRequest(req, false);
Enumeration enu = null;
Map renderParameters = null;
boolean portletFocus = false;
if (_portletName.equals(req.getParameter(
WebKeys.PORTLET_URL_PORTLET_NAME))) {
// Request was targeted to this portlet
boolean action = ParamUtil.getBoolean(
req, WebKeys.PORTLET_URL_ACTION);
if (!action) {
// Request was triggered by a render URL
portletFocus = true;
}
else if (action && isAction()) {
// Request was triggered by an action URL and is being processed
// by com.liferay.portlet.ActionRequestImpl
portletFocus = true;
}
}
if (portletFocus) {
renderParameters = new HashMap();
RenderParametersPool.put(
req, layoutId, _portletName, renderParameters);
enu = req.getParameterNames();
}
else {
renderParameters = RenderParametersPool.get(
req, layoutId, _portletName);
enu = Collections.enumeration(renderParameters.keySet());
}
String prefix = PortalUtil.getPortletNamespace(_portletName);
while (enu.hasMoreElements()) {
String param = (String)enu.nextElement();
if (param.startsWith(prefix)) {
String newParam =
param.substring(prefix.length(), param.length());
String[] values = null;
if (portletFocus) {
if (req instanceof UploadServletRequest) {
UploadServletRequest uploadServletReq = (UploadServletRequest)req;
if(uploadServletReq.getFile(param) == null) {
values = uploadServletReq.getParameterValues(param);
} else {
values = new String[0];
}
} else {
values = req.getParameterValues(param);
}
renderParameters.put(param, values);
}
else {
values = (String[])renderParameters.get(param);
}
dynamicReq.setParameterValues(newParam, values);
}
else {
// Allow regular parameters to pass through
if (!PortalUtil.isReservedParameter(param)) {
String[] values = null;
if (portletFocus) {
values = req.getParameterValues(param);
renderParameters.put(param, values);
}
else {
values = (String[])renderParameters.get(param);
}
dynamicReq.setParameterValues(param, values);
}
}
}
_req = dynamicReq;