掲示板

deep linking inside jsf portlet from outside

9年前 に Eric Soucy によって更新されました。

deep linking inside jsf portlet from outside

Junior Member 投稿: 65 参加年月日: 14/01/21 最新の投稿
Hi,
from my jsf portlet, I need to redirect to a third party site and give this site a " return URL" that leads back to a specific view inside my portlet within the same session.
This view must be different than my starting point.
From this third party site, the user will perform an action and be redirected to the " return URL".

With liferay and JSF, how can I build this return URL ?


Thanks
Eric
thumbnail
9年前 に Neil Griffin によって更新されました。

RE: deep linking inside jsf portlet from outside

Liferay Legend 投稿: 2655 参加年月日: 05/07/27 最新の投稿
Hi Eric,

I would recommend that the return URL should be a portlet RenderURL and you can navigate to a different viewId with Bridge.FACES_VIEW_ID_PARAMETER. For example:

<portlet:renderURL var="#{returnURL}">
<portlet:param name="_jsfBridgeViewId" value="/views/otherView.xhtml" />
</portlet:renderURL>

<a href="#{returnURL}">click here to navigate to the returnURL via HTTP GET</a>

Kind Regards,

Neil
9年前 に Eric Soucy によって更新されました。

RE: deep linking inside jsf portlet from outside

Junior Member 投稿: 65 参加年月日: 14/01/21 最新の投稿
Thanks,
I need to do this programmaticaly since I must provide this "return url" in a http rest call.
How can I create a renderURL with the API ?

Thanks again

Eric


Neil Griffin:
Hi Eric,

I would recommend that the return URL should be a portlet RenderURL and you can navigate to a different viewId with Bridge.FACES_VIEW_ID_PARAMETER. For example:

<portlet:renderURL var="#{returnURL}">
<portlet:param name="_jsfBridgeViewId" value="/views/otherView.xhtml" />
</portlet:renderURL>

<a href="#{returnURL}">click here to navigate to the returnURL via HTTP GET</a>

Kind Regards,

Neil
9年前 に Eric Soucy によって更新されました。

RE: deep linking inside jsf portlet from outside

Junior Member 投稿: 65 参加年月日: 14/01/21 最新の投稿
i dont want to show the return url in my view, just pass it along to 3rd party external site.
here is what i've done

        PortletDisplay portletDisplay= themeDisplay.getPortletDisplay();
        String portletId = portletDisplay.getId();

        com.liferay.portal.kernel.portlet.LiferayPortletURL myActionURL  = PortletURLFactoryUtil.create(req, portletId, themeDisplay.getPlid(), "1");
        myActionURL.setParameter("_jsfBridgeViewId", "/views/view3.xhtml");

but this gives me :
https://localhost:8443/web/test/test-portlet?p_p_id=&amp;___jsfBridgeViewId=%2Fviews%2Fview3.xhtml


what I need is this :

https://localhost:8443/web/test/test-portlet?p_p_id=portlettestnetbanx_WAR_portlettestnetbanx&amp;p_p_lifecycle=0&amp;p_p_state=normal&amp;p_p_mode=view&amp;p_p_col_id=column-1&amp;p_p_col_count=1&amp;_portlettestnetbanx_WAR_portlettestnetbanx__jsfBridgeViewId=%2Fviews%2Fview3.xhtml
         * this also works
         * https://localhost:8443/web/test/test-portlet?p_p_id=portlettestnetbanx_WAR_portlettestnetbanx&amp;p_p_lifecycle=0&amp;_portlettestnetbanx_WAR_portlettestnetbanx__jsfBridgeViewId=%2Fviews%2Fview3.xhtml
         * and this also works as well: https://localhost:8443/web/test/test-portlet?p_p_id=portlettestnetbanx_WAR_portlettestnetbanx&amp;_portlettestnetbanx_WAR_portlettestnetbanx__jsfBridgeViewId=%2Fviews%2Fview3.xhtml
9年前 に Eric Soucy によって更新されました。

RE: deep linking inside jsf portlet from outside

Junior Member 投稿: 65 参加年月日: 14/01/21 最新の投稿
It works I did it like this :

FacesContext fCtx = FacesContext.getCurrentInstance();
        PortletRequest req = (PortletRequest) fCtx.getExternalContext().getRequest();
        ThemeDisplay themeDisplay = (ThemeDisplay) req.getAttribute(WebKeys.THEME_DISPLAY);
        Layout layout = themeDisplay.getLayout();
        PortletDisplay portletDisplay= themeDisplay.getPortletDisplay();
        String portletId = PortalUtil.getPortletId(req);
        com.liferay.portal.kernel.portlet.LiferayPortletURL myActionURL  = PortletURLFactoryUtil.create(req, portletId, themeDisplay.getPlid(),        PortletRequest.RENDER_PHASE);
      
       myActionURL.setParameter("_jsfBridgeViewId", "/views/view3.xhtml");

thumbnail
9年前 に Neil Griffin によって更新されました。

RE: deep linking inside jsf portlet from outside

Liferay Legend 投稿: 2655 参加年月日: 05/07/27 最新の投稿
Hi Eric,

Thanks for posting your solution. You might also be able to do it with fewer lines of code by using the standards-based JSF API, Portlet API, and Bridge API, like this:

FacesContext facesContext = FacesContext.getCurrentInstance();
MimeResponse mimeResponse = (MimeResponse) facesContext.getExternalContext.getResponse();
PortletURL renderURL = mimeResponse.createRenderURL();
renderURL.setParameter(Bridge.FACES_VIEW_ID_PARAMETER, "/views/view3.xhtml");


Kind Regards,

Neil
9年前 に Eric Soucy によって更新されました。

RE: deep linking inside jsf portlet from outside

Junior Member 投稿: 65 参加年月日: 14/01/21 最新の投稿
When I try your solution (which seems better than mine btw) i get the following error

15:47:37,170 ERROR [http-bio-8443-exec-16][status_jsp:750] com.liferay.portal.kernel.portlet.PortletContainerException: javax.portlet.faces.BridgeException: javax.portlet.faces.BridgeException: javax.faces.FacesException: #{paiementBean.submitPayment}: java.lang.ClassCastException: com.liferay.portlet.ActionResponseImpl cannot be cast to javax.portlet.MimeResponse
com.liferay.portal.kernel.portlet.PortletContainerException: javax.portlet.faces.BridgeException: javax.portlet.faces.BridgeException: javax.faces.FacesException: #{paiementBean.submitPayment}: java.lang.ClassCastException: com.liferay.portlet.ActionResponseImpl cannot be cast to javax.portlet.MimeResponse
at com.liferay.portlet.PortletContainerImpl.processAction(PortletContainerImpl.java:113)
thumbnail
9年前 に Neil Griffin によって更新されました。

RE: deep linking inside jsf portlet from outside

Liferay Legend 投稿: 2655 参加年月日: 05/07/27 最新の投稿
Hi Eric,

Are you programmatically constructing the URL during the ACTION_PHASE of the portlet lifecycle for a particular reason? For example, perhaps you are doing a redirect.

Normally URL construction is done during the RENDER_PHASE, which is why you are seeing the ClassCastException.

Kind Regards,

Neil
9年前 に Eric Soucy によって更新されました。

RE: deep linking inside jsf portlet from outside

Junior Member 投稿: 65 参加年月日: 14/01/21 最新の投稿
yes that is exactly it, I need to do a redirect.
so is my proposed solution the way to go ?

Thanks
thumbnail
9年前 に Neil Griffin によって更新されました。

RE: deep linking inside jsf portlet from outside

Liferay Legend 投稿: 2655 参加年月日: 05/07/27 最新の投稿
Hi Eric,

If you are including the return URL as a parameter on the redirect URL, then yes I think you would need to stick with the solution you came up with. The Portlet API does not provide a way for MimeResponse.create*() methods to be used in your use-case.

Kind Regards,

Neil