Foros de discusión
How to generate the most consistent Portlet URL?
Fernando Cabrera, modificado hace 9 años.
How to generate the most consistent Portlet URL?
Junior Member Mensajes: 47 Fecha de incorporación: 1/08/14 Mensajes recientes
Hello, I would like to generate an absolute URL associated to the page where my custom portlet is, but not related to the current session/request (p_auth parameter) because I need that the URL to be available in future occasions.
To give more context to the question. I'm developing a portlet that generates user notifications, so at the end, the link is going to be in the dockbar, that is the reason to be absolute and "inter-session"
Current approach is:
And that generate some URL like this:
What is the best way to generate the URL?
Thanks!
To give more context to the question. I'm developing a portlet that generates user notifications, so at the end, the link is going to be in the dockbar, that is the reason to be absolute and "inter-session"
Current approach is:
FacesContext facesContext = FacesContext.getCurrentInstance();
ExternalContext externalContext = facesContext.getExternalContext();
PortletRequest portletRequest = (PortletRequest) externalContext.getRequest();
ServiceContext serviceContext = ServiceContextFactory.getInstance(portletRequest);
String portletId = serviceContext.getPortletId();
long plid = serviceContext.getPlid();
String lifecycle = PortletRequest.ACTION_PHASE;
LiferayPortletURL portletURL = PortletURLFactoryUtil.create(portletRequest, portletId, plid, lifecycle);
And that generate some URL like this:
http://localhost:8081/web/guest/inicio?p_auth=1TNzy9Cz&p_p_id=notificationtestportlet_WAR_notificationtestportlet&p_p_lifecycle=1
What is the best way to generate the URL?
Thanks!
David H Nebinger, modificado hace 9 años.
RE: How to generate the most consistent Portlet URL?
Liferay Legend Mensajes: 14919 Fecha de incorporación: 2/09/06 Mensajes recientes
You're creating a URL based upon the FacesContext of the portlet itself.
To generate a portal URL, I think you'll have to rely upon portal facilities instead of portlet ones.
To generate a portal URL, I think you'll have to rely upon portal facilities instead of portlet ones.
Fernando Cabrera, modificado hace 9 años.
RE: How to generate the most consistent Portlet URL?
Junior Member Mensajes: 47 Fecha de incorporación: 1/08/14 Mensajes recientes
Thank you David for reply
I think I made a mistake by omitting some information in my question.
The URL also include some request parameters necessaries to implement some business logic in manage bean. For that, I thought that the URL should be based on the portlet, but maybe I'm wrong I don't know
What I am looking for answer is something more code-oriented, because I'm lost between many utility and service classes that sometimes makes the same (apparently) and because maybe there is already some class or method that do exactly what I need and I just don't know.
Finally, I complemented my question with more information in another forum thread
I think I made a mistake by omitting some information in my question.
The URL also include some request parameters necessaries to implement some business logic in manage bean. For that, I thought that the URL should be based on the portlet, but maybe I'm wrong I don't know
What I am looking for answer is something more code-oriented, because I'm lost between many utility and service classes that sometimes makes the same (apparently) and because maybe there is already some class or method that do exactly what I need and I just don't know.
Finally, I complemented my question with more information in another forum thread