Foren

Liferay 6 FriendlyURLMapping with a Spring portlet

Anjali Mahna, geändert vor 12 Jahren.

Liferay 6 FriendlyURLMapping with a Spring portlet

New Member Beiträge: 4 Beitrittsdatum: 07.07.10 Neueste Beiträge
I'm having a difficult time getting friendly urls rendered using Liferay FriendlyURLMapping configuration for a Spring portlet. Any working sample would be greatly appreciated.

I expect the portlet:actionURLs in the jsp to be rendered in a friendly url format on the UI but don't see the expected results. An attempt to write a CustomFriendlyURLMApper class doesn't work either since the bindPath method is never getting invoked (break point never hit in debug mode). Need some good suggestions to proceed with this.

Thanks,
Anjali
thumbnail
Raja Nagendra Kumar, geändert vor 12 Jahren.

RE: Liferay 6 FriendlyURLMapping with a Spring portlet

Expert Beiträge: 484 Beitrittsdatum: 02.03.06 Neueste Beiträge
>I'm having a difficult time getting friendly urls rendered using Liferay FriendlyURLMapping configuration for a Spring portlet. Any working sample would be greatly appreciated.

Nothing specific to spring (portlet) is needed...

>I expect the portlet:actionURLs in the jsp to be rendered in a friendly url format on the UI

I think this may not be possible.. based on the way liferay has implemented friendly URL..

>but don't see the expected results. An attempt to write a CustomFriendlyURLMApper class doesn't work either since the bindPath method is never getting invoked (break point never hit >in debug mode). Need some good suggestions to proceed with this.

Could you check your liferay-portlet.xml

as in the wiki
http://www.liferay.com/community/wiki/-/wiki/Main/FriendlyURLMapper for portlet level handling

use urlrewrite approach for context level handling.
http://www.liferay.com/web/jonas.yuan/blog/-/blogs/making-home-url-and-web-content-seo-friendly-url-highly-configurable-in-multiple-web-sites

Regards,
Raja Nagendra Kumar,
C.T.O
www.tejasoft.com
Anjali Mahna, geändert vor 12 Jahren.

RE: Liferay 6 FriendlyURLMapping with a Spring portlet

New Member Beiträge: 4 Beitrittsdatum: 07.07.10 Neueste Beiträge
Thanks for the feedback. I appreciate your answer.


>I expect the portlet:actionURLs in the jsp to be rendered in a friendly url format on the UI

I think this may not be possible.. based on the way liferay has implemented friendly URL.
.


The wiki seemed to indicate that friendly urls would be displayed from Portlet:renderUrls as long as the url matched the routes. I did already try modifying the jsp to use friendly routes and the appropriate method was not invoked based on a specific parameter (am using annotated spring controller).


>but don't see the expected results. An attempt to write a CustomFriendlyURLMApper class doesn't work either since the bindPath method is never getting invoked (break point never hit >in debug mode). Need some good suggestions to proceed with this.

Could you check your liferay-portlet.xml


Here is my liferay-portlet.xml to use custom mapper class which did never work.
<portlet>
<portlet-name>mymove-deals</portlet-name>
<icon>/icon.png</icon>
<friendly-url-mapper-class>com.imagitas.mymove.mydeals.util.DealsFriendlyUrlMapper</friendly-url-mapper-class>
<friendly-url-mapping>deals</friendly-url-mapping>
<instanceable>false</instanceable>
<header-portlet-css>/css/myDeals.css</header-portlet-css>
<header-portlet-javascript>/js/myDeals.js</header-portlet-javascript>
</portlet>

Let me know if you see something obviously wrong here.

Thanks again for the feedback !!
thumbnail
Raja Nagendra Kumar, geändert vor 12 Jahren.

RE: Liferay 6 FriendlyURLMapping with a Spring portlet

Expert Beiträge: 484 Beitrittsdatum: 02.03.06 Neueste Beiträge
Could check friendly URL first with JSR 168 portlet.. if it works.. then try to convert to spring annotated one..
Martin Phee, geändert vor 12 Jahren.

RE: Liferay 6 FriendlyURLMapping with a Spring portlet

Junior Member Beiträge: 25 Beitrittsdatum: 09.05.11 Neueste Beiträge
I was never able to get this to work with the renderURL. I always have to use the actionURL. But.... You can hack it.

public class MartysFriendlyURLMapper extends DefaultFriendlyURLMapper {
@Override
public void populateParams(String friendlyURLPath, Map<String, String[]> parameterMap, Map<String, Object> requestContext) {
super.populateParams(friendlyURLPath, parameterMap, requestContext);
addParameter(parameterMap, "p_auth", AuthTokenUtil.getToken((HttpServletRequest)requestContext.get("request")));
}
}


<?xml version="1.0"?>
<!DOCTYPE routes PUBLIC "-//Liferay//DTD Friendly URL Routes 6.0.0//EN" "http://www.liferay.com/dtd/liferay-friendly-url-routes_6_0_0.dtd">
<routes>
<route>
<pattern>/{selectedLink}</pattern>
<implicit-parameter name="p_p_lifecycle">1</implicit-parameter>
<implicit-parameter name="javax.portlet.action">switchMenu</implicit-parameter>
</route>