Community Contributions

Other
PUBLIC PROFILE

Back to topics

General Discussion

RendetParameter lost when pass parameter from a a sub class of IPortletAction to a viewer

You need to be logged in to post messages

RendetParameter lost when pass parameter from a a sub class of IPortletAction to a viewer

8/6/2012 6:06 AM EDT

Hi Matt,

For below code in a sub class of IPortletAction, if the portlet is in a page such as http://localhost:8080/connect/businesses.shtml or http://localhost:8080/connect/, the corresponding viewer class(a sub class of IPortletViewer) can get these parameter using RenderRequest.getParameter(). But if the portlet is in a project page such as http://localhost:8080/connect/show/listing-11, the corresponding viewer class alwayse get null value returned by RenderRequest.getParameter().

response.setWindowState(WindowState.MAXIMIZED);
response.setRenderParameter("out", "text");
response.setRenderParameter("ajax", "true");
response.setRenderParameter("limit", request.getParameter("limit"));

I think this problem is related with your change to pluto related with ProjectPortalURLParserImpl.java. Could you tell me some hint on which source code can be changed to fix the problem?

Right now I have to use PortletSession to pass parameters from sub class of IPortletAction to viewer.

BTW, in connect 2.0.2, the problem has cause that the 'delete activity' function in activity stream portlet in a project page does not work well, even after I comment the source code line "response.setRenderParameter("offset", request.getParameter("offset"));" which actually always throw exception.

Thanks,
Baogang

1. 8/6/2012 11:19 AM EDT

Hi Matt,

When a portlet is in a project page such as http://localhost:8080/connect/show/listing-11, in action class, response.setRenderParameter("portlet-params", "?param1=value1&param2=value2") can be used to pass parameters to viewer. But this way does not work when the portlet is in page http://localhost:8080/connect/businesses.shtml.

If changing ProjectPortalURLParserImpl.toString(PortalURL portalURL), by adding some new code line in the place 'ADD_CODE_HERE' in code below, such like always call <appendParameter(buffer, param.getName() + "=" + param.getValues()\); > and bypass the code after 'ADD_CODE_HERE', the problem can be solved, but I am not clear on the side effect.

For the code below, all the 'if' condition after 'ADD_CODE_HERE' get 'false' value, so where the appendParameter is not called. How can I do some change on code after 'ADD_CODE_HERE' to fix the problem without getting side effect?

} else if ("out".equals(param.getName()))
if (StringUtils.hasText(param.getValues()\))
appendParameter(buffer, param.getName() + "=" + param.getValues()\);
}
continue;
} else if ("popup".equals(param.getName()))
if (StringUtils.hasText(param.getValues()\))
appendParameter(buffer, param.getName() + "=" + param.getValues()\);
}
continue;
}
 
// ADD_CODE_HERE

// Encode action params in the query appended at the end of the URL.
if (portalURL.getActionWindow() != null
&& portalURL.getActionWindow().equals(param.getWindowId()))
for (int i = 0; i < param.getValues().length; i++)
if (StringUtils.hasText(param.getValues()\))
appendParameter(buffer, param.getName() + "=" + param.getValues()\);
}
}
} else if (param.getValues() != null && param.getValues().length > 0)
// Encode the parameter ONLY if it targets the currently being rendered portlet
if (param.getWindowId().equals(portalURL.getRenderPath()))
// The Project Portal uses clean URLs, so portlet window targeting is not used
if (!buffer.toString().contains("?" + param.getName() + "=") &&
!buffer.toString().contains("&" + param.getName() + "="))
String valueString = encodeMultiValues(param.getValues());

Thanks,

Baogang

2. 8/6/2012 9:54 PM EDT

Hi Matt,

I fixed the problem as in below code. The change to ProjectPortalURLParserImpl.toString() is similar with code in PortalURLParserImpl.toString(), that is, comment the line:

"if (param.getWindowId().equals(portalURL.getRenderPath())) ".

I am not sure whether this change will affect the function of other connect code.ChangeOfProjectPortalURLParserImpl.java.png

Thanks,

Baogang

3. 8/7/2012 8:10 AM EDT
Default user photo

By Matt Rajkowski

Concursive Corporation
Product Design

airplane-icon-100x100.png

Hi Baogang,

I'm looking at your continued progress here and have a contribution too.

For the benefit of others I wanted to mention that many of the URLs in Connect have been cleaned up from a standard portal. This has the benefit of making the URLs understandable by users and for security and SEO benefits as well. To make this happen, the underlying URL parser from Pluto has been modified for the "profile" pages and the contained portlets.

To use multiple render parameters I think the following works:

} else if (param.getValues() != null && param.getValues().length > 0)

LOG.debug("Appending parameters... " + param.getWindowId());

// The Project Portal uses clean URLs, so portlet window targeting is not used

if (!buffer.toString().contains("?" + param.getName() + "=") &&

!buffer.toString().contains("&" + param.getName() + "="))

String valueString = encodeMultiValues(param.getValues());

if (valueString.length() > 0)

appendParameter(buffer, param.getName() + "=" + valueString);

}

} else

// If param already exists, replace the value

}

}

4. 8/7/2012 9:40 PM EDT

Hi Matt,

Thank you very much!

Thanks,

Baogang

4 results found