Reputation: 10714
The goal is to create a URL to the Portlet with this code:
ExternalContext ctx = FacesContext.getCurrentInstance().getExternalContext();
RenderResponse response = (RenderResponse)ctx.getResponse();
PortletURL portletUrl = response.createRenderURL();
String url = portletUrl .toString();
But if I call this in a backing bean's JSF-actionListener method, I get a ClassCastException
because ctx.getResponse()
gives me an javax.portlet.ActionResponse
instead.
I know that a RenderResponse
is accessible from the doView
method in the Portlet class. But how can I access it in my backing bean?
Upvotes: 1
Views: 1613
Reputation: 10714
I use the following approach now, which causes some (very little) workload overhead, but works well:
RenderResponse
in the doView
methodPortletURL portletUrl = response.createRenderURL();
and store this object in the portlet session (with every request, I know).PortletURL
object, append neccessary parameters and render the URL for whatever.Upvotes: 0
Reputation: 108969
I'd like to put link into an email that leads the user to the portlet. I'm using WebSphere Portal 6.1.
The render URL is not normally available at that point in the portlet lifecycle.
In both these cases, you don't need the huge encoded URL usually generated by Portal; you use something like http://host/foo/bar
as your entry point.
I've used the second approach in production. Unique names are added to the target pages and portlet instances for easy lookup. These are added to the page configuration via XMLAccess scripts - they are not available via the admin user interface in version 6.1.
Upvotes: 1