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?
I use the following approach now, which causes some (very little) workload overhead, but works well:
RenderResponsein thedoViewmethodPortletURL portletUrl = response.createRenderURL();and store this object in the portlet session (with every request, I know).PortletURLobject, append neccessary parameters and render the URL for whatever.