Fórumok
Generating Liferay URL in Velocity template for Web Content Display
Erik Nielsen, módosítva 11 év-val korábban
Generating Liferay URL in Velocity template for Web Content Display
New Member Bejegyzések: 3 Csatlakozás dátuma: 2012.06.25. Legújabb bejegyzések
I would like to be able to use portletURLFactory to create a URL in a velocity template for the Web Content Display portlet. Unfortunately, according to these links, we don't have access to a real HttpServletRequest object here (and it's odd that we have access to portletURLFactory in this case).
Is there any way to get around this without using friendly URLs for any portlets to which you want to link? What I'd like to do (and what doesn't work) is something like:
However, $url will not be populated because the call to create will not work, as far as I understand, because $request is not the real HttpServeletRequest.
Thanks,
Erik
Is there any way to get around this without using friendly URLs for any portlets to which you want to link? What I'd like to do (and what doesn't work) is something like:
#set($plid = $getterUtil.getLong($portalUtil.getPlidFromPortletId($getterUtil.getLong($groupId), "portletName")))
#set($url = $portletURLFactory.create($request, "portletName", $plid, "RENDER_PHASE"))
## set some other parameters on the url
## include the link
However, $url will not be populated because the call to create will not work, as far as I understand, because $request is not the real HttpServeletRequest.
Thanks,
Erik
jelmer kuperus, módosítva 11 év-val korábban
RE: Generating Liferay URL in Velocity template for Web Content Display (Válasz)
Liferay Legend Bejegyzések: 1191 Csatlakozás dátuma: 2010.03.10. Legújabb bejegyzések
You could use javascript : http://www.liferay.com/web/eduardo.lundgren/blog/-/blogs/liferay-portleturl-in-javascript
Erik Nielsen, módosítva 11 év-val korábban
RE: Generating Liferay URL in Velocity template for Web Content Display
New Member Bejegyzések: 3 Csatlakozás dátuma: 2012.06.25. Legújabb bejegyzések
Jelmer,
Is there a way to ensure that the portlet_url.js file gets included on a page? I know I can configure portlets to include specific JS files, but this isn't included in the page I'm building on which I'm putting the Web Content Display. Otherwise, that looks like a great solution.
Thanks,
Erik
Is there a way to ensure that the portlet_url.js file gets included on a page? I know I can configure portlets to include specific JS files, but this isn't included in the page I'm building on which I'm putting the Web Content Display. Otherwise, that looks like a great solution.
Thanks,
Erik
jelmer kuperus, módosítva 11 év-val korábban
RE: Generating Liferay URL in Velocity template for Web Content Display (Válasz)
Liferay Legend Bejegyzések: 1191 Csatlakozás dátuma: 2010.03.10. Legújabb bejegyzések
You include the module something like this :
AUI().ready('liferay-portlet-url', function(A) {
... code goes here
});
Erik Nielsen, módosítva 11 év-val korábban
RE: Generating Liferay URL in Velocity template for Web Content Display
New Member Bejegyzések: 3 Csatlakozás dátuma: 2012.06.25. Legújabb bejegyzések
Thanks, that's exactly what I needed.
Erik
Erik
Michel Wicky, módosítva 11 év-val korábban
RE: Generating Liferay URL in Velocity template for Web Content Display
Regular Member Bejegyzések: 130 Csatlakozás dátuma: 2010.07.03. Legújabb bejegyzések
Hello Erik,
Did you got it ?
I cannot achiveve the class initialization, i don't why, may be you will find the reason or let us know about your code so i can compare.
Here is an abstract from the velocity web content template :
#foreach ($userOrganization in $userOrganizations)
#if ($userOrganization.getParentOrganization().getGroupId() == 10698)
#set ($httpRequest = $portalUtil.getHttpServletRequest())
#set ($myPlaceURL = $portletFactoryUtil.create($httpRequest, "49", $userOrganization.getGroup().getDefaultPublicPlid(), "ACTION_PHASE"))
#set ($myPlaceURL2 = $portletFactoryUtil.create($request, "49", $userOrganization.getGroup().getDefaultPublicPlid(), "ACTION_PHASE"))
$userOrganization.getGroup().getDefaultPublicPlid()
$myPlaceURL.toString()
$myPlaceURL2.toString()
## $myPlaceURL.setWindowState("normal")
## $myPlaceURL.setPortletMode("view")
## $myPlaceURL.setParameter("struts_action", "/my_places/view")
## $myPlaceURL.setParameter("groupId", $userOrganization.getGroupId().toString())
## $myPlaceURL.setParameter("privateLayout", "false")
## $myPlaceURL.toString()
<li><a href="${myPlaceURL.toString()}">$userOrganization.Name</a></li>
#set ($matched = $matched + 1)
#end
#end
Thank you
Did you got it ?
I cannot achiveve the class initialization, i don't why, may be you will find the reason or let us know about your code so i can compare.
Here is an abstract from the velocity web content template :
#foreach ($userOrganization in $userOrganizations)
#if ($userOrganization.getParentOrganization().getGroupId() == 10698)
#set ($httpRequest = $portalUtil.getHttpServletRequest())
#set ($myPlaceURL = $portletFactoryUtil.create($httpRequest, "49", $userOrganization.getGroup().getDefaultPublicPlid(), "ACTION_PHASE"))
#set ($myPlaceURL2 = $portletFactoryUtil.create($request, "49", $userOrganization.getGroup().getDefaultPublicPlid(), "ACTION_PHASE"))
$userOrganization.getGroup().getDefaultPublicPlid()
$myPlaceURL.toString()
$myPlaceURL2.toString()
## $myPlaceURL.setWindowState("normal")
## $myPlaceURL.setPortletMode("view")
## $myPlaceURL.setParameter("struts_action", "/my_places/view")
## $myPlaceURL.setParameter("groupId", $userOrganization.getGroupId().toString())
## $myPlaceURL.setParameter("privateLayout", "false")
## $myPlaceURL.toString()
<li><a href="${myPlaceURL.toString()}">$userOrganization.Name</a></li>
#set ($matched = $matched + 1)
#end
#end
Thank you
Tejas Kanani, módosítva 10 év-val korábban
RE: Generating Liferay URL in Velocity template for Web Content Display
Liferay Master Bejegyzések: 654 Csatlakozás dátuma: 2009.01.06. Legújabb bejegyzések
Hi Michel,
Did you find any solution for this ? I am also not able to get HttpRequest in WCM template.
Thanks,
Tejas
Did you find any solution for this ? I am also not able to get HttpRequest in WCM template.
Thanks,
Tejas
Mazhar Alam, módosítva 10 év-val korábban
RE: Generating Liferay URL in Velocity template for Web Content Display
Regular Member Bejegyzések: 191 Csatlakozás dátuma: 2011.11.25. Legújabb bejegyzések
I am also trying to create a sign in url into the webcontent. Still am trying to achieve this by templates and methods posted here.
If anyone have tried this, then do let me know.
Thanks
If anyone have tried this, then do let me know.
Thanks
Aritz Galdos, módosítva 8 év-val korábban
RE: Generating Liferay URL in Velocity template for Web Content Display
Expert Bejegyzések: 416 Csatlakozás dátuma: 2007.05.15. Legújabb bejegyzések
Hi Mazhar Alam
I had the same problem creating a portletURL object from velocity
This is the signature
PortletURLFactory.create(PortletRequest portletRequest, String portletId, long plid, String lifecycle)
Notice that plid requires a long type whereas the class of the $plid object available in velocity is String.
For me, this did the trick
And then use $plidLong as param for PortletURLFactory.create
Hope that helps.
Regards
I had the same problem creating a portletURL object from velocity
This is the signature
PortletURLFactory.create(PortletRequest portletRequest, String portletId, long plid, String lifecycle)
Notice that plid requires a long type whereas the class of the $plid object available in velocity is String.
For me, this did the trick
set($tmp = 0)
#set ($plidLong = $tmp.parseInt($plid))
And then use $plidLong as param for PortletURLFactory.create
Hope that helps.
Regards
Balázs Csönge, módosítva 8 év-val korábban
RE: Generating Liferay URL in Velocity template for Web Content Display
Regular Member Bejegyzések: 107 Csatlakozás dátuma: 2014.11.10. Legújabb bejegyzések
Hi All,
There is no working solution in this tread.
The problem with th PortletURLFactory.create(PortletRequest portletRequest, String portletId, long plid, String lifecycle) method, not really the plid. Yes of course, you must cast it to long with $getterUtil.getLong(), but the real pain the portletRequest input parameter.
Can anybody show a WORKING soluton on liferay 6.2?!
$request is a hashMap, the theme-display in it a hashMap too
$xmlRequest is a string which made from PortletRequest with toXml(method), but I did not find any method to convert it back.
Is any way to get the request in velocity as httpServletRequest or PortletRequest object?!?
I found the following, which is NOT working:
Something else?
There is no working solution in this tread.
The problem with th PortletURLFactory.create(PortletRequest portletRequest, String portletId, long plid, String lifecycle) method, not really the plid. Yes of course, you must cast it to long with $getterUtil.getLong(), but the real pain the portletRequest input parameter.
Can anybody show a WORKING soluton on liferay 6.2?!
$request is a hashMap, the theme-display in it a hashMap too
$xmlRequest is a string which made from PortletRequest with toXml(method), but I did not find any method to convert it back.
Is any way to get the request in velocity as httpServletRequest or PortletRequest object?!?
I found the following, which is NOT working:
#set ($serviceContext = $portal.getClass().forName("com.liferay.portal.service.ServiceContextThreadLocal").getServiceContext())
#set ($httpServletRequest = $serviceContext.getRequest())
Something else?
Sachin Mane, módosítva 11 év-val korábban
RE: Generating Liferay URL in Velocity template for Web Content Display
Junior Member Bejegyzések: 76 Csatlakozás dátuma: 2012.04.10. Legújabb bejegyzések
i believe you will have access to PortletRequest (RenderRequesT) in the template.
You can use PortalUtil.getHttpServletRequest (PortletRequest portletRequest) to get the http request and then use PortletUrlFactory.
You can use PortalUtil.getHttpServletRequest (PortletRequest portletRequest) to get the http request and then use PortletUrlFactory.