-
1. Re: Portal URL Parameters pass to Portlet ?
mwringe Jun 7, 2010 1:16 PM (in response to mstuart1521)That is not going to work, you should not be adding portlet url parameters to a portal url.
-
2. Re: Portal URL Parameters pass to Portlet ?
joel-the-wanna-be-programr Jun 10, 2010 5:36 PM (in response to mstuart1521)You should be able to pass parameters and see then in the action phase of your portlet. See: http://community.jboss.org/wiki/PortletParameters
It works in 2.7.2.
-
3. Re: Portal URL Parameters pass to Portlet ?
artmunro2 Jun 11, 2010 9:09 AM (in response to joel-the-wanna-be-programr)Does this work in Gatein? Mark have you tried this?
-
4. Re: Portal URL Parameters pass to Portlet ?
csorbazoli Jun 25, 2010 5:18 AM (in response to mstuart1521)Hi,
I'm facing the same problem.
I'd like to access portal request parameters or portal URL from the portlets, but I don't know how.
I need to implement restful URL's for the portal.
For example:
Original URL: http://localhost:8080/myportal/item-123
This should be redirected (with url rewrite filter) to: http://localhost:8080/myportal/showItem?id=123
There is a showItem portal page, which contains a portlet that should show given item details.
How could I access the request parameter 'id' from the portlet context?
Maybe I'm wrong, and this not a good solution for handling 'nice' URLs in a portal?
I'm using: GateIn-3.0.0-GA, PortletBridge-2.0.0.FINAL, Seam-2.2.0.GA
Thank you in advance
-
5. Re: Portal URL Parameters pass to Portlet ?
csorbazoli Jun 30, 2010 10:21 AM (in response to csorbazoli)The solution I've found is the combination of org.tuckey UrlRewriteFilter and a PhaseListener.
The PhaseListener implementation is based on this blogpost: http://blogs.steeplesoft.com/2006/04/jsf-phaselisteners-and-get-requests/
The main difference is, that I've extended the configuration with portlet path info. This means, I can configure parameter handling rules per portlet. This helps avoiding repeated execution of parameter injections (because the phase listener is executed once for each portlet instances on a portal page).
That's all.
-
6. Re: Portal URL Parameters pass to Portlet ?
jferreyram Aug 25, 2010 12:33 AM (in response to csorbazoli)Hi ZoltÃin.
Could you show me some of your source code of PhaseListener? Especially, how you did get the url of portal, because, when I try get it, an exception is thrown:
context = FacesContext.getCurrentInstance(); HttpServletRequest request = (HttpServletRequest)context.getExternalContext().getRequest(); String uri = request.getRequestURI();
The exception is produced because the method getRequest returns an RenderRequest object , but it needs a HttpServletRequest object. The problem is I don't have any idea about how to get the HttpServletRequest.
if you have any example of this I would appreciate your help.
I'm using Gatein 3.0.0-GA and JBossPortetBridge 2.0.0.FINAL
-
7. Re: Portal URL Parameters pass to Portlet ?
csorbazoli Aug 25, 2010 5:11 AM (in response to jferreyram)Hi Jorge,
I use org.gatein.pc.portlet.impl.jsr168.api.RenderRequestImpl and javax.servlet.http.HttpServletRequestWrapper.
{code}
private void debugRequest(RenderRequestImpl renderRequest, HttpServletRequestWrapper hsrw) {
RequestParamHandlerPhaseListener.logger.debug("URI: " + hsrw.getRequestURI());
RequestParamHandlerPhaseListener.logger.debug("Portlet request path info: " + renderRequest.getAttribute("org.jboss.seam.web.requestPathInfo"));
if (RequestParamHandlerPhaseListener.logger.isTraceEnabled()) {
RequestParamHandlerPhaseListener.logger.trace(" Parameters...");
@SuppressWarnings("unchecked")
Map<String, String[]> params = hsrw.getParameterMap();
for (String key : params.keySet()) {
RequestParamHandlerPhaseListener.logger.trace(" param: " + key + " = " + Arrays.toString(params.get(key)));
}
RequestParamHandlerPhaseListener.logger.trace(" End of parameters");
}
}
@Override
public PhaseId getPhaseId() {
// TODO read configuration...
return PhaseId.RESTORE_VIEW;
}
private void processRequest() {
FacesContext context = FacesContext.getCurrentInstance();
ExpressionFactory ef = context.getApplication().getExpressionFactory();
Object reqObj = context.getExternalContext().getRequest();
if (RequestParamHandlerPhaseListener.logger.isTraceEnabled()) {
RequestParamHandlerPhaseListener.logger.trace("Request class: #0", reqObj.getClass().getName());
}
if (reqObj instanceof RenderRequestImpl) {
RequestParamHandlerPhaseListener.logger.trace("Handling RenderRequest...");
RenderRequestImpl renderRequest = (RenderRequestImpl) reqObj;
HttpServletRequestWrapper hsrw = renderRequest.getRealRequest();
if (RequestParamHandlerPhaseListener.logger.isDebugEnabled()) {
this.debugRequest(renderRequest, hsrw);
}
String uri = hsrw.getRequestURI();
String contextPath = hsrw.getContextPath();
// comment: there is no static field for "org.jboss.seam.web.requestPathInfo"
String reqPathInfo = (String) renderRequest.getAttribute("org.jboss.seam.web.requestPathInfo");
// reqPathInfo is the viewId of currently processed portlet
// TODO process request URI and parameters...
}
}
{code}
I hope it helps you.
Regards,
Zoltan
-
8. Re: Portal URL Parameters pass to Portlet ?
jferreyram Aug 25, 2010 1:51 PM (in response to csorbazoli)It works!. Thank you very much, Zoltan.
-
9. Re: Portal URL Parameters pass to Portlet ?
hoang_to Aug 27, 2010 3:00 AM (in response to mstuart1521)From coming release 3.2, some navigational properties of portal would be accessible as portlet public render parameter. Here is link to relevant JIRA
-
10. Re: Portal URL Parameters pass to Portlet ?
antoine_h Apr 10, 2012 2:48 AM (in response to hoang_to)Also, with the release 3.2, a Url factory and decoder has been added.
This will allow to manage more easily the url building and url use.
See : http://community.jboss.org/en/gatein?view=blog
chapter : "Improved URLs"
And the Navigation Controller :
The Navigation Controller should be helpfull for what you need.
Antoine
JBoss Portal and GateIn, JSF, Richfaces, J2EE.
-
11. Re: Portal URL Parameters pass to Portlet ?
sreenureddy20 Sep 25, 2012 9:49 AM (in response to mstuart1521)Hi,
How can we get PortletUrl in jsr268 into portlet controller or into jsp ???
-
12. Re: Portal URL Parameters pass to Portlet ?
vstorm83 Sep 25, 2012 9:41 PM (in response to sreenureddy20)For jsp, you can use Portlet Tag Library, the details is in JSR 268 spec. For example, you can have a tag like this to generate action url:
<portlet:actionURL windowState=”maximized” portletMode=”edit” name=”editStocks”>
</portlet:actionURL>
In your portlet class, you can use RenderResponse#createRenderURL , this is also mentioned in JSR 268
-
13. Re: Portal URL Parameters pass to Portlet ?
antoine_h Sep 30, 2012 1:36 PM (in response to vstorm83)Hi,
you have also plenty of sample in the code of GateIn itself.
look into the Groovy files (".gtmpl"), there are many samples of how to build some url of other pages, with parameters, etc...
thoses files are in the code source, but also in the server, directly readable when the ear and war are not zipped.
make a search with the PortletUrl key word, etc...
you can adapt things from the Groovy sample, to the JSP (quite similar way of doing these kind of things...)
Antoine
JBoss Portal, EPP, and GateIn, J2EE, JSF, Richfaces, JBoss AS7.