Foros de discusión

How to get a request parameter in the URL in JSF?

Elvin Wong, modificado hace 15 años.

How to get a request parameter in the URL in JSF?

Junior Member Mensajes: 30 Fecha de incorporación: 29/01/07 Mensajes recientes
Hi,

I am using Liferay, Icefaces.

I would like to get a parameter from a URL
e.g. www.hostname.com/item?id=12345

I would like to display the item details according to the id number in the request parameter.
How can I get the "id" value from a JSF Bean?

Thank you very much
Best Regards,
Elvin
thumbnail
Tobias Amon, modificado hace 15 años.

RE: How to get a request parameter in the URL in JSF?

Liferay Master Mensajes: 546 Fecha de incorporación: 8/08/07 Mensajes recientes
Hi,

as you are working on portlets, you cannot get "normal" request parameters. You can only get request parameters which are "sent" to the portlet itself.

If you have this URL:
http://somserver/somepage?p_p_id=some_portlet_id_INSTANCEID&p_p_action=0&p_p_state=maximized&param=value
you can get the value of the "param" parameter only in the portlet whose ID is "some_portlet_id"

kind regards
Tobias
thumbnail
Tobias Amon, modificado hace 15 años.

RE: How to get a request parameter in the URL in JSF?

Liferay Master Mensajes: 546 Fecha de incorporación: 8/08/07 Mensajes recientes
Hi,

me again.

If you have the correct URL for the portlet you can get the values with this code:

        FacesContext context = FacesContext.getCurrentInstance();
        Map<string, string> paramMap = context.getExternalContext().getRequestParameterMap();
        String projectId = paramMap.get("param");</string,>


kind regards
Tobias
Elvin Wong, modificado hace 15 años.

RE: How to get a request parameter in the URL in JSF?

Junior Member Mensajes: 30 Fecha de incorporación: 29/01/07 Mensajes recientes
Hi Tobias,

Thank you for your answer and the code, it works.

Actually I was wondering "PortalUtil" could give us some tricks to access the HTTPServlet and
hence the request parameters.....

I tried below but all throws exceptions
============================================

try {
logger.debug(" --- PortalUtil ---");
logger.debug("getPathFriendlyURLPublic = " + PortalUtil.getPathFriendlyURLPublic());
logger.debug("getCurrentURL = " + PortalUtil.getCurrentURL((PortletRequest) context.getExternalContext().getRequest()));

HttpServletRequest request = PortalUtil.getHttpServletRequest(
(PortletRequest) context.getExternalContext().getRequest());

logger.debug(" id = " + request.getParameter("id"));
logger.debug("HttpServletRequest Map = " + request.getParameterMap());
} catch (Exception e) {
logger.error("Error", e);
}

try {
HttpServletRequest request =
(HttpServletRequest) context.getExternalContext().getRequestMap().get("com.liferay.portal.kernel.servlet.PortletServletRequest");
logger.debug(" --- com.liferay.portal.kernel.servlet.PortletServletRequest ---");
logger.debug(" id = " + request.getParameter("id"));
logger.debug("HttpServletRequest Map = " + request.getParameterMap());
} catch (Exception e) {
logger.error("Error", e);
}
chinna singareddy, modificado hace 13 años.

How to make JSF portlet in Netbeans IDE 6.5.1 & procedure

New Member Mensajes: 3 Fecha de incorporación: 16/11/10 Mensajes recientes
Please help me how to make JSF portlet in Netbeans IDE 6.5.1
Elvin Wong, modificado hace 15 años.

RE: How to get a request parameter in the URL in JSF?

Junior Member Mensajes: 30 Fecha de incorporación: 29/01/07 Mensajes recientes
Hi,

Actually, I would like to have make a friendly URL.
Let's take a liferay's example, to getting back to this post, we can use the following link

http://www.liferay.com/web/guest/community/forums/-/message_boards/message/1994365

However, this forum is actually a portlet, right? Liferay don't need to provide a portlet Id to retreive this post.
So, I guess there is someway(or tricks?) to get the request parameters without passing the portlet Id.

Please kindly help if anybody knows the way to do it.

Many thanks,

Best Regards,
Elvin
thumbnail
Tobias Amon, modificado hace 15 años.

RE: How to get a request parameter in the URL in JSF?

Liferay Master Mensajes: 546 Fecha de incorporación: 8/08/07 Mensajes recientes
Hi,

liferay is working with struts... the URL you can see is a struts-url where the struts servlet includes some jsp pages to the servlet response. Using JSF you always have your fix URL's to your JSP/XHTML pages. You cannot have such URL's in JSF...

kind regards
Tobias
Elvin Wong, modificado hace 15 años.

RE: How to get a request parameter in the URL in JSF?

Junior Member Mensajes: 30 Fecha de incorporación: 29/01/07 Mensajes recientes
Hi Tobias,


I don't quite get the point.....
Do you mean, using struct to build a portlet, the portlet can get the request parameters in the URL,
(the struct servlet can get the request param and pass to the jsp that it includes...right?)
but using JSF, it cannot?


Thank you very much.
Best Regards,
Elvin
thumbnail
Tobias Amon, modificado hace 15 años.

RE: How to get a request parameter in the URL in JSF?

Liferay Master Mensajes: 546 Fecha de incorporación: 8/08/07 Mensajes recientes
Hi,

Struts and JSF are 2 completely different techniques.

In Struts, your actions are encoded in the URL. The action that a portlet is executing is defined with this URL.
I'm not a Struts specialist, so I cannot explain it with more details...

kind regards
Tobias
Elvin Wong, modificado hace 15 años.

RE: How to get a request parameter in the URL in JSF?

Junior Member Mensajes: 30 Fecha de incorporación: 29/01/07 Mensajes recientes
Hi Tobias,


I am now much more clear about how it works.

Thank you very much.

Best Regards,
Elvin
Elvin Wong, modificado hace 15 años.

RE: How to get a request parameter in the URL in JSF?

Junior Member Mensajes: 30 Fecha de incorporación: 29/01/07 Mensajes recientes
Hi Tobias,

Do you have experience with Icefaces?
When I use icefaces, I cannot get the parameters in the way that you suggest.
Do you have any idea?

Thank you very much.
Best Regards,
Elvin
thumbnail
Tobias Amon, modificado hace 15 años.

RE: How to get a request parameter in the URL in JSF?

Liferay Master Mensajes: 546 Fecha de incorporación: 8/08/07 Mensajes recientes
Hi Elvin,

actually I have some experience with ICEfaces. I developed several portlets with ICEfaces for my company.

And the code snippets are taken from my productive portlets. So I think they do work.

What did you do so far? Configuration, code, ....

kind regards
Tobias
Elvin Wong, modificado hace 15 años.

RE: How to get a request parameter in the URL in JSF?

Junior Member Mensajes: 30 Fecha de incorporación: 29/01/07 Mensajes recientes
Hi Tobias,

That is great that you have experience! Thanks advance!

My case is that.

In my icefaces page, I use the following code to generate a URL that contains a portletId and a param that is an id of a product

Code
===========================================================
RenderResponse renderResponse =
(RenderResponse) FacesContext.getCurrentInstance().getExternalContext().getResponse();
PortletURL portletURL = renderResponse.createActionURL();
portletURL.setParameter("id", "12345");
renderURL = portletURL.toString();
logger.debug("portletURL = " + portletURL.toString());

URL generated
===========================================================
http://localhost:8080/web/item?p_p_id=product_detail_portlet_WAR_WebAppName_INSTANCE_27qA&amp;p_p_lifecycle=1&amp;p_p_state=normal&amp;p_p_mode=view&amp;p_p_col_id=column-2&amp;p_p_col_count=1&amp;_product_detail_portlet_WAR_WebAppName_INSTANCE_27qA_id=12345

In the item page i.e. http://localhost:8080/web/item, it call a "showDetail" method via the JSF page
(Same portlet, same jspx page that generate the URL, )
============================================================================
<ice:panelGrid rendered="#{productBean.showDetail}" cellpadding="2" cellspacing="2" width="100%" columns="2">
...
...

In the showDetail method of the bean, I try to print out all the values into my log file
================================================================
FacesContext context = FacesContext.getCurrentInstance();
if (logger.isDebugEnabled()) {
Map paramMap = context.getExternalContext().getRequestParameterMap();
Iterator iter = paramMap.keySet().iterator();
while (iter.hasNext()) {
String paramKey = (String) iter.next();
logger.debug("paramKey = " + paramKey + " value = " + paramMap .get(paramKey).toString());

}
}
return context.getExternalContext().getRequestParameterMap().get(key);


---> And There has no value contains in the RequestParameterMap()


So I try "getRequestMap" instead
========================================================
FacesContext context = FacesContext.getCurrentInstance();
if (logger.isDebugEnabled()) {
Map paramMap = context.getExternalContext().getRequestMap();
Iterator iter = paramMap.keySet().iterator();
while (iter.hasNext()) {
String paramKey = (String) iter.next();
logger.debug("paramKey = " + paramKey + " value = " + paramMap.get(paramKey).toString());

}
}
return context.getExternalContext().getRequestMap().get(key);



There indeed some values contained in the requestMap but not the id that I have passed to the instance.
=================================================================================
com.wf.common.bean.BasicBean - paramKey = javax.faces.webapp.COMPONENT_TAG_STACK value = [com.sun.faces.taglib.jsf_core.ViewTag@9fbddf, com.icesoft.faces.component.portlet.PortletTag@16a925c, com.icesoft.faces.component.FormTag@1aeec48]
com.wf.common.bean.BasicBean - paramKey = javax.servlet.include.request_uri value = /WebAppName/item/detail.iface
com.wf.common.bean.BasicBean - paramKey = com.icesoft.faces.portlet.artifact value = com.icesoft.faces.webapp.http.portlet.PortletArtifactWrapper@11a9d12
com.wf.common.bean.BasicBean - paramKey = com.icesoft.faces.PORTLET value = portlet
com.wf.common.bean.BasicBean - paramKey = com.liferay.portal.kernel.servlet.PortletServletConfig value = org.apache.catalina.core.StandardWrapperFacade@169fb09
com.wf.common.bean.BasicBean - paramKey = com.liferay.portal.kernel.servlet.PortletServletResponse value = com.liferay.portal.kernel.servlet.StringServletResponse@3e1abf
com.wf.common.bean.BasicBean - paramKey = javax.portlet.config value = com.liferay.portlet.PortletConfigImpl@d37bd8
com.wf.common.bean.BasicBean - paramKey = com.icesoft.faces.NAMESPACE value = _detail_portlet_WAR_WebAppName_INSTANCE_27qA_
com.wf.common.bean.BasicBean - paramKey = productBean value = com.wf.product.bean.productBean@14e063d
com.wf.common.bean.BasicBean - paramKey = javax.faces.webapp.GLOBAL_ID_VIEW value = {_detail_portlet_WAR_WebAppName_INSTANCE_27qA_:productDetailForm=com.icesoft.faces.component.FormTag@1aeec48}
com.wf.common.bean.BasicBean - paramKey = javax.servlet.include.context_path value = /WebAppName
com.wf.common.bean.BasicBean - paramKey = com.liferay.portal.kernel.servlet.PortletServletFilterChain value = com.sun.portal.portletcontainer.appengine.filter.FilterChainImpl@17b9183
com.wf.common.bean.BasicBean - paramKey = com.liferay.portal.kernel.servlet.PortletServletRequest value = com.liferay.portal.servlet.NamespaceServletRequest@18e5318
com.wf.common.bean.BasicBean - paramKey = javax.servlet.include.servlet_path value = /search/item/detail.iface
com.wf.common.bean.BasicBean - paramKey = basicBean value = com.wf.common.bean.BasicBean@f16719
com.wf.common.bean.BasicBean - paramKey = com.sun.faces.managedBeanStack value = []
com.wf.common.bean.BasicBean - paramKey = javax.portlet.request value = com.liferay.portlet.RenderRequestImpl@a7bdab
com.wf.common.bean.BasicBean - paramKey = javax.portlet.response value = com.liferay.portlet.RenderResponseImpl@9548c3
com.wf.common.bean.BasicBean - paramKey = THEME_DISPLAY value = com.liferay.portal.theme.ThemeDisplay@9a57a0





And I try to request.getAttribute but no value again...

Do you have any idea that where I possible make mistake or...I headed the wrong direction?

Thank you very much.
Best Regards,
Elvin
thumbnail
Tobias Amon, modificado hace 15 años.

RE: How to get a request parameter in the URL in JSF?

Liferay Master Mensajes: 546 Fecha de incorporación: 8/08/07 Mensajes recientes
Hi,

why do you need to get the request paramter?

If I understand you correct, you are not trying to pass the parameter to a different portlet, right? You are trying to open the details page in the same portlet!

So you don't need that stuff at all. Is this your first JSF application?

If yes... you might need to learn some more things about that. If not.... did you never work with session-scoped beans where you can store a selected item and retrieve it in a different page?

kind regards
Tobias
Elvin Wong, modificado hace 15 años.

RE: How to get a request parameter in the URL in JSF?

Junior Member Mensajes: 30 Fecha de incorporación: 29/01/07 Mensajes recientes
Hi Tobias,

Yes I am not trying to pass a param to a different portlet....

Yes I have done some JSF before, I know it's not a usual way (may be not proper way also)
to get the param from the URL.

However, it's because after user have done a search, I want to let the user to
bookmark the search result and come back to the searched item again,
by using the same URL.

This is the reason behind.

I have make a little modification of the Liferay Journal Article Portlet
using similiar method as above. The generated URL can always leads to the
same result. (Even works for a different portlet on a different page)
i.e. The user can bookmark the URL.

However, using JSF I have difficulties to doing so.
I don't know if there is a way to get the param from the URL.
(I think I must miss something, as JSF did provide the API,
I think there is a way to get the param....)

Do you have any idea what I did wrong?


Thank you very much.


Best Regards,
Elvin
thumbnail
Tobias Amon, modificado hace 15 años.

RE: How to get a request parameter in the URL in JSF?

Liferay Master Mensajes: 546 Fecha de incorporación: 8/08/07 Mensajes recientes
Hi,

OK.. so now I see clearer. In fact you are trying to pass a parameter to a different portlet. Not during search, but when coming back to the result (after bookmarking it).

Actually I don't know what you are doing wrong as the code I posted is working for me.

Maybe the generated URL is not correct. Here is what you posted: http://localhost:8080/web/item?p_p_id=product_detail_portlet_WAR_WebAppName_INSTANCE_27qA&amp;p_p_lifecycle=1&amp;p_p_state=normal&amp;p_p_mode=view&amp;p_p_col_id=column-2&amp;p_p_col_count=1&amp;_product_detail_portlet_WAR_WebAppName_INSTANCE_27qA_id=12345

I think there is a problem with the "&amp;". I assume the paramter is named "_product_detail_portlet_WAR_WebAppName_INSTANCE_27qA_id". Try this url:
http://localhost:8080/web/item?p_p_id=product_detail_portlet_WAR_WebAppName_INSTANCE_27qA&p_p_lifecycle=1&p_p_state=normal&p_p_mode=view&p_p_col_id=column-2&p_p_col_count=1&_product_detail_portlet_WAR_WebAppName_INSTANCE_27qA_id=12345

kind regards
Tobias
Elvin Wong, modificado hace 15 años.

RE: How to get a request parameter in the URL in JSF?

Junior Member Mensajes: 30 Fecha de incorporación: 29/01/07 Mensajes recientes
Hi Tobias,

Thank you for your reply...
I have tried to replace, however, it throws an exception.
I don't know what's wrong.
However, after I take out the following param, the portlet can show properly but the "id" value still unable to obtain.


&p_p_lifecycle=1&p_p_state=normal

Do you have any idea?

Thank you very much!

Best Regards,
Elvin


Error Code
================================================================
21:54:46,406 DEBUG http-8080-Processor19 com.icesoft.faces.context.View - Disposing com.icesoft.faces.context.View$5@869e50
21:54:46,421 ERROR http-8080-Processor19 org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/WebApp].[product_detail_portlet] - Servlet.service() for servlet product_detail_portlet threw exception
javax.portlet.PortletException: processAction method not implemented
at javax.portlet.GenericPortlet.processAction(GenericPortlet.java:177)
at com.sun.portal.portletcontainer.appengine.filter.FilterChainImpl.doFilter(FilterChainImpl.java:93)
at com.liferay.portal.kernel.servlet.PortletServlet.service(PortletServlet.java:103)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:679)
at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:584)
at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:497)
at com.liferay.portlet.InvokerPortlet.invoke(InvokerPortlet.java:550)
at com.liferay.portlet.InvokerPortlet.processAction(InvokerPortlet.java:310)
at com.liferay.portal.action.LayoutAction.processPortletRequest(LayoutAction.java:589)
at com.liferay.portal.action.LayoutAction.processLayout(LayoutAction.java:386)
at com.liferay.portal.action.LayoutAction.execute(LayoutAction.java:186)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
at com.liferay.portal.struts.PortalRequestProcessor.process(PortalRequestProcessor.java:163)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
at com.liferay.portal.servlet.MainServlet.callParentService(MainServlet.java:409)
at com.liferay.portal.servlet.MainServlet.service(MainServlet.java:638)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:98)
at com.liferay.portal.servlet.filters.virtualhost.VirtualHostFilter.doFilter(VirtualHostFilter.java:149)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:98)
at com.liferay.portal.servlet.filters.sessionid.SessionIdFilter.doFilter(SessionIdFilter.java:81)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:679)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:461)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:399)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:301)
at com.liferay.portal.servlet.FriendlyURLServlet.service(FriendlyURLServlet.java:138)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:98)
at com.liferay.portal.servlet.filters.strip.StripFilter.doFilter(StripFilter.java:91)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:98)
at com.liferay.portal.servlet.filters.compression.CompressionFilter.doFilter(CompressionFilter.java:111)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:98)
at com.liferay.portal.servlet.filters.secure.SecureFilter.doFilter(SecureFilter.java:205)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:98)
at com.liferay.portal.servlet.filters.doubleclick.DoubleClickFilter.doFilter(DoubleClickFilter.java:134)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:98)
at com.liferay.portal.servlet.filters.layoutcache.LayoutCacheFilter.doFilter(LayoutCacheFilter.java:191)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:98)
at com.liferay.portal.servlet.filters.autologin.AutoLoginFilter.doFilter(AutoLoginFilter.java:142)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:98)
at com.liferay.portal.servlet.filters.virtualhost.VirtualHostFilter.doFilter(VirtualHostFilter.java:173)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:98)
at com.liferay.portal.servlet.filters.sessionid.SessionIdFilter.doFilter(SessionIdFilter.java:81)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:874)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
at java.lang.Thread.run(Thread.java:595)
thumbnail
Tobias Amon, modificado hace 15 años.

RE: How to get a request parameter in the URL in JSF?

Liferay Master Mensajes: 546 Fecha de incorporación: 8/08/07 Mensajes recientes
Hi,

actually you created an action URL. The generic portlet for JSF does not support this. You need to generate a "normal" render-URL. You don't need the action-URL at all as you simply render the portlet (from a portlet point of view) and process the data using JSF... JSF doesn't know anything about portlets.

kind regards
Tobias
Elvin Wong, modificado hace 15 años.

RE: How to get a request parameter in the URL in JSF?

Junior Member Mensajes: 30 Fecha de incorporación: 29/01/07 Mensajes recientes
Hi Tobias,

Thank you for your answer.

I almost forget it's about portlet not JSF.

Best Regards,
Elvin
Markus Braasch, modificado hace 15 años.

RE: How to get a request parameter in the URL in JSF?

New Member Mensaje: 1 Fecha de incorporación: 9/02/09 Mensajes recientes
The other solutions described here did not work for me within my portlet. I used the sample-jsf-1.1-sun-facelets portlet as a basis. After trying a number of different things I gained access to the request parameter using this code:

		...
		FacesContext context = FacesContext.getCurrentInstance();
		Map<string,string[]> originalParams = getPortalRequest(context).getParameterMap();
		if (originalParams.get("articleId") != null)
			log.info("RequestParameter articleId: " + originalParams.get("articleId")[0]);
	}

	public static ServletRequest getPortalRequest(FacesContext context) {
		Map<string,object> requests = context.getExternalContext().getRequestMap();
		for (String requestName : requests.keySet()) {
			if (requests.get(requestName) instanceof HttpServletRequestWrapper) {
				return ((HttpServletRequestWrapper) requests.get(requestName)).getRequest();
			}
		}
		return null;
	}</string,object></string,string[]>


A more complete description of this solution can be found at this URL: How to Access Global Request Parameters in JSF Portlet

I hope you will find this useful,
Markus