掲示板
Issues with Friendly URL and DefaultFriendlyURLMapper
13年前 に Markus Ziller によって更新されました。
Issues with Friendly URL and DefaultFriendlyURLMapper
New Member 投稿: 18 参加年月日: 10/07/14 最新の投稿
Hi there,
As my title may suggest i'm currently facing issues with liferay 6's friendly url. what i'm trying to do is:
i developed a portlet that can be used for creating events, manage attendences and some more stuff.
an url that refers to an event is like the following:
http://localhost:8080/web/guest/events?p_auth=EkgoCvT1&p_p_id=meetupsportlet_WAR_meetupsportlet_INSTANCE_kNW3&p_p_lifecycle=1&p_p_state=normal&p_p_mode=view&p_p_col_id=column-1&p_p_col_count=1&_meetupsportlet_WAR_meetupsportlet_INSTANCE_kNW3_javax.portlet.action=SHOW_DETAILS&event_id=9900
Since this URL is very unhandy to remember or to pass it to anyone, i'm trying to shorten it via the friendly URL feature:
Basically the only information i need out of this whole "wall of text", is the event_id
So what im trying to get is sth. like http://localhost:8080/web/guest/events/9900 or maybe http://localhost:8080/web/guest/events/details/9900.
changed the liferay-portlet.xml as follows:
and created a eventRoutes.xml that currently only contains
At this point i don't know what to do next and so i was hoping you could give me a hint how to geht that ugly URLs shortened
Any help is appreciated
thanks in advance
Markus
As my title may suggest i'm currently facing issues with liferay 6's friendly url. what i'm trying to do is:
i developed a portlet that can be used for creating events, manage attendences and some more stuff.
an url that refers to an event is like the following:
http://localhost:8080/web/guest/events?p_auth=EkgoCvT1&p_p_id=meetupsportlet_WAR_meetupsportlet_INSTANCE_kNW3&p_p_lifecycle=1&p_p_state=normal&p_p_mode=view&p_p_col_id=column-1&p_p_col_count=1&_meetupsportlet_WAR_meetupsportlet_INSTANCE_kNW3_javax.portlet.action=SHOW_DETAILS&event_id=9900
Since this URL is very unhandy to remember or to pass it to anyone, i'm trying to shorten it via the friendly URL feature:
Basically the only information i need out of this whole "wall of text", is the event_id
So what im trying to get is sth. like http://localhost:8080/web/guest/events/9900 or maybe http://localhost:8080/web/guest/events/details/9900.
changed the liferay-portlet.xml as follows:
<liferay-portlet-app>
<portlet>
<portlet-name>meetups-portlet</portlet-name>
<icon>/icon.png</icon>
<friendly-url-mapper-class>com.liferay.portal.kernel.portlet.DefaultFriendlyURLMapper</friendly-url-mapper-class>
<friendly-url-mapping>events</friendly-url-mapping>
<friendly-url-routes>../eventRoutes.xml</friendly-url-routes>
...</portlet></liferay-portlet-app>
and created a eventRoutes.xml that currently only contains
<!--?xml version="1.0"?-->
<routes>
<route>
<pattern>events/{event_id}/</pattern>
<implicit-parameter name="event_id"></implicit-parameter>
</route>
</routes>
At this point i don't know what to do next and so i was hoping you could give me a hint how to geht that ugly URLs shortened
Any help is appreciated
thanks in advance
Markus
13年前 に Sébastien Meunier によって更新されました。
RE: Issues with Friendly URL and DefaultFriendlyURLMapper
Junior Member 投稿: 33 参加年月日: 10/01/26 最新の投稿
Hello,
I suppose you've used this article from the wiki to get there. If not you should read it.
The only problem I see in your files is that the <pattern> should start with a /.
It should give you an url like this one : http://localhost:8080/web/guest/events/-/events/events/9900
All those "events" correspond to these fields in your xml files :
http://localhost:8080/web/guest/(page name)/-/<friendly-url-mapping>/<pattern>
If your event id is a number, you may want to specify it in the pattern by doing <pattern>/events/{event_id:\d+}/</pattern>.
I suppose you've used this article from the wiki to get there. If not you should read it.
The only problem I see in your files is that the <pattern> should start with a /.
It should give you an url like this one : http://localhost:8080/web/guest/events/-/events/events/9900
All those "events" correspond to these fields in your xml files :
http://localhost:8080/web/guest/(page name)/-/<friendly-url-mapping>/<pattern>
If your event id is a number, you may want to specify it in the pattern by doing <pattern>/events/{event_id:\d+}/</pattern>.
13年前 に Markus Ziller によって更新されました。
RE: Issues with Friendly URL and DefaultFriendlyURLMapper
New Member 投稿: 18 参加年月日: 10/07/14 最新の投稿
hi, thank you for your response
sadly i still couldn't figure out why it doesn't work.
to this point i tested nearly every possible combination of parameter settings, pattern (with / as well as without) and ...
the only result i got was that i grew some more grey hairs, which is quite unsatisfying.
can you figure out ANY possible reason why this doesn't work or maybe provide any hint where to look for the error.
thanks a lot
Markus
sadly i still couldn't figure out why it doesn't work.
to this point i tested nearly every possible combination of parameter settings, pattern (with / as well as without) and ...
the only result i got was that i grew some more grey hairs, which is quite unsatisfying.
can you figure out ANY possible reason why this doesn't work or maybe provide any hint where to look for the error.
thanks a lot
Markus
13年前 に Sébastien Meunier によって更新されました。
RE: Issues with Friendly URL and DefaultFriendlyURLMapper
Junior Member 投稿: 33 参加年月日: 10/01/26 最新の投稿
Hello,
I just noticed from the url in your first post that your portlet is instanceable.
So your friendly url must have the instanceId included in the pattern, something like this :
I just noticed from the url in your first post that your portlet is instanceable.
So your friendly url must have the instanceId included in the pattern, something like this :
<route>
<pattern>/{instanceId}/events/{event_id}/</pattern>
<implicit-parameter name="event_id"></implicit-parameter>
</route>
13年前 に Puj Z によって更新されました。
RE: Issues with Friendly URL and DefaultFriendlyURLMapper
Regular Member 投稿: 220 参加年月日: 10/01/14 最新の投稿
Hi Markus,
you can also make your portlet not-instanciable, if you do not need more than one instance of your portlet in one page (which I believe is the case with event-management, right?)
In order to do it, go to your liferay-portlet.xml and set instanciable tag to false:
<liferay-portlet-app>
<portlet>
<portlet-name>blabla</portlet-name>
<icon>/icon.png</icon>
<instanceable>false</instanceable>
<header-portlet-css>/css/style.css</header-portlet-css>
<header-portlet-javascript>/js/bla.js</header-portlet-javascript>
</portlet>
Cheers.
you can also make your portlet not-instanciable, if you do not need more than one instance of your portlet in one page (which I believe is the case with event-management, right?)
In order to do it, go to your liferay-portlet.xml and set instanciable tag to false:
<liferay-portlet-app>
<portlet>
<portlet-name>blabla</portlet-name>
<icon>/icon.png</icon>
<instanceable>false</instanceable>
<header-portlet-css>/css/style.css</header-portlet-css>
<header-portlet-javascript>/js/bla.js</header-portlet-javascript>
</portlet>
Cheers.
13年前 に Markus Ziller によって更新されました。
RE: Issues with Friendly URL and DefaultFriendlyURLMapper
New Member 投稿: 18 参加年月日: 10/07/14 最新の投稿
thanks pujan,
i just did so, but withour the desired effect. what i now have is:
liferay-portlet.xml:
eventRoutes.xml:
Event-URLs follow the following pattern:
although everything seems to be correct configured, it just doesnt work, which starts to freak me out..
Any other ideas what my problem may be?
thanks a lot
Markus
i just did so, but withour the desired effect. what i now have is:
liferay-portlet.xml:
<liferay-portlet-app>
<portlet>
<portlet-name>meetups-portlet</portlet-name>
<icon>/icon.png</icon>
<friendly-url-mapper-class>com.liferay.portal.kernel.portlet.DefaultFriendlyURLMapper</friendly-url-mapper-class>
<friendly-url-mapping>events</friendly-url-mapping>
<friendly-url-routes>../eventRoutes.xml</friendly-url-routes>
<instanceable>false</instanceable>
<header-portlet-css>/css/main.css</header-portlet-css>
<header-portlet-javascript>/js/jquery-1.4.2.js</header-portlet-javascript>
<footer-portlet-javascript>/js/main.js</footer-portlet-javascript>
<css-class-wrapper>meetups-portlet</css-class-wrapper>
</portlet></liferay-portlet-app>
eventRoutes.xml:
<routes>
<route>
<pattern>/events/{event_id}/</pattern>
<implicit-parameter name="event_id"></implicit-parameter>
</route>
</routes>
Event-URLs follow the following pattern:
http://localhost:8080/web/guest/events?p_auth=EBGej3rW&p_p_id=meetupsportlet_WAR_meetupsportlet&p_p_lifecycle=1&p_p_state=normal&p_p_mode=view&p_p_col_id=column-1&p_p_col_count=1&_meetupsportlet_WAR_meetupsportlet_javax.portlet.action=SHOW_DETAILS&event_id=9900
although everything seems to be correct configured, it just doesnt work, which starts to freak me out..
Any other ideas what my problem may be?
thanks a lot
Markus
13年前 に Puj Z によって更新されました。
RE: Issues with Friendly URL and DefaultFriendlyURLMapper
Regular Member 投稿: 220 参加年月日: 10/01/14 最新の投稿
Strange.
Maybe some of Liferay staff have any idea why this doesn't work?
Maybe some of Liferay staff have any idea why this doesn't work?
13年前 に Puj Z によって更新されました。
RE: Issues with Friendly URL and DefaultFriendlyURLMapper
Regular Member 投稿: 220 参加年月日: 10/01/14 最新の投稿
Hi Markus,
I see
<friendly-url-routes>../eventRoutes.xml</friendly-url-routes>
and usually in liferay they use a complete path, like for example in message board portlet:
<friendly-url-routes>com/liferay/portlet/messageboards/message-boards-friendly-url-routes.xml</friendly-url-routes>
and the .xml file is at
src/com/liferay/portlet/messageboards/message-boards-friendly-url-routes.xml
Considering you are using a relative path, are you sure your .xml file is at the right address?
I see
<friendly-url-routes>../eventRoutes.xml</friendly-url-routes>
and usually in liferay they use a complete path, like for example in message board portlet:
<friendly-url-routes>com/liferay/portlet/messageboards/message-boards-friendly-url-routes.xml</friendly-url-routes>
and the .xml file is at
src/com/liferay/portlet/messageboards/message-boards-friendly-url-routes.xml
Considering you are using a relative path, are you sure your .xml file is at the right address?
13年前 に Milton Waddams によって更新されました。
RE: Issues with Friendly URL and DefaultFriendlyURLMapper
New Member 投稿: 4 参加年月日: 10/10/29 最新の投稿
I'm trying to resolve the exact same issue as Markus. I am also trying to follow the wiki article .
My URL looks like
My portlet XML is
And my route xml is
I can confirm that Liferay is able to access the route XML because when I ignore parameters it actually removes parameters. e.g.
The above route removes most of the parameters and gives me the following URL
But as you can see it leaves the "p_auth" parameter that makes it impossible for me to give the URL to someone else.
I'm still not quite sure I completely understand how the route xml works and would really appreciate any additional pointers or next steps.
Thanks in advance
My URL looks like
http://localhost:8080/web/guest/test?p_auth=m5H8XQYc&p_p_id=searchboxportlet_WAR_SamplePortletportlet&p_p_lifecycle=1&p_p_state=normal&p_p_mode=view&p_p_col_id=column-2&p_p_col_count=2&_searchboxportlet_WAR_SamplePortletportlet_query=test&_searchboxportlet_WAR_SamplePortletportlet_search=Search
My portlet XML is
<portlet>
<portlet-name>searchboxportlet</portlet-name>
<icon>/icon.png</icon>
<friendly-url-mapper-class>com.liferay.portal.kernel.portlet.DefaultFriendlyURLMapper</friendly-url-mapper-class>
<friendly-url-mapping>search_friendly_display</friendly-url-mapping>
<friendly-url-routes>com/test/package/search-friendly-url-routes.xml</friendly-url-routes>
<instanceable>false</instanceable>
<private-request-attributes>false</private-request-attributes>
<private-session-attributes>false</private-session-attributes>
<header-portlet-css>/css/portlet.css</header-portlet-css>
<footer-portlet-javascript>
/js/javascript.js
</footer-portlet-javascript>
<css-class-wrapper>searchboxportlet-portlet</css-class-wrapper>
</portlet>
And my route xml is
<routes>
<route>
<pattern>/query/{query}</pattern>
<implicit-parameter name="query"></implicit-parameter>
</route>
</routes>
I can confirm that Liferay is able to access the route XML because when I ignore parameters it actually removes parameters. e.g.
<routes>
<route>
<pattern></pattern>
<ignored-parameter name="p_p_col_id" />
<ignored-parameter name="p_p_col_count" />
<ignored-parameter name="p_p_mode" />
<ignored-parameter name="p_p_state" />
</route>
</routes>
The above route removes most of the parameters and gives me the following URL
http://localhost:8080/web/guest/test/-/search_friendly_display?p_auth=m5H8XQYc&p_p_lifecycle=1&_searchboxportlet_WAR_SamplePortletportlet_query=test&_searchboxportlet_WAR_SamplePortletportlet_search=Search
But as you can see it leaves the "p_auth" parameter that makes it impossible for me to give the URL to someone else.
I'm still not quite sure I completely understand how the route xml works and would really appreciate any additional pointers or next steps.
Thanks in advance
13年前 に Pedro Guedes によって更新されました。
RE: Issues with Friendly URL and DefaultFriendlyURLMapper
New Member 投稿: 1 参加年月日: 10/11/03 最新の投稿
Experiencing something similar here...
With friendly routes applied the url still carries the p_auth parameter. Removing it causes a PrincipalException to be thrown "Invalid authentication token".
Any ideas how to work around this?
(I saw somewhere in this forum someone suggesting disabling the p_auth check.. but that does not feel right)
Thanks,
Pedro
With friendly routes applied the url still carries the p_auth parameter. Removing it causes a PrincipalException to be thrown "Invalid authentication token".
Any ideas how to work around this?
(I saw somewhere in this forum someone suggesting disabling the p_auth check.. but that does not feel right)
Thanks,
Pedro
13年前 に Milton Waddams によって更新されました。
RE: Issues with Friendly URL and DefaultFriendlyURLMapper
New Member 投稿: 4 参加年月日: 10/10/29 最新の投稿
I was finally able to the routing to work (partially) for my case using the following XML
However, I'm still unable to hide the p_auth parameter. I see the "Document Library" portlet from Liferay doing it but I couldn't figure out how, any pointers there would help.
<routes>
<route>
<pattern>/{search}</pattern>
<implicit-parameter name="p_p_id">searchboxportlet_WAR_SamplePortletportlet</implicit-parameter>
<implicit-parameter name="p_p_lifecycle">1</implicit-parameter>
</route>
</routes>
However, I'm still unable to hide the p_auth parameter. I see the "Document Library" portlet from Liferay doing it but I couldn't figure out how, any pointers there would help.
13年前 に Markus Ziller によって更新されました。
RE: Issues with Friendly URL and DefaultFriendlyURLMapper
New Member 投稿: 18 参加年月日: 10/07/14 最新の投稿
Hi all,
I made some progress in solving my problem. Im now at the same point that milton is.
The Event-URLs look like:
The problem im stil facing at this point is, that p_auth, as well as event_id, aren't hidden.
Since milton has the same troubles with p_auth, i'd probably assume its a malfunction of liferay. I also believe that the problem with not hiding "event_id" is related to this.
Maybe some liferay staff could write some sentences to this issue.
Thanks in advance, markus
I made some progress in solving my problem. Im now at the same point that milton is.
The Event-URLs look like:
http://localhost:8080/web/guest/events/-/events/SHOW_DETAILS/?p_auth=ArUrV4F6&event_id=947
The problem im stil facing at this point is, that p_auth, as well as event_id, aren't hidden.
Since milton has the same troubles with p_auth, i'd probably assume its a malfunction of liferay. I also believe that the problem with not hiding "event_id" is related to this.
Maybe some liferay staff could write some sentences to this issue.
Thanks in advance, markus
12年前 に Eduard Saldaña によって更新されました。
RE: Issues with Friendly URL and DefaultFriendlyURLMapper
New Member 投稿: 19 参加年月日: 11/03/09 最新の投稿Markus Ziller:
Hi all,
I made some progress in solving my problem. Im now at the same point that milton is.
The Event-URLs look like:http://localhost:8080/web/guest/events/-/events/SHOW_DETAILS/?p_auth=ArUrV4F6&event_id=947
The problem im stil facing at this point is, that p_auth, as well as event_id, aren't hidden.
Since milton has the same troubles with p_auth, i'd probably assume its a malfunction of liferay. I also believe that the problem with not hiding "event_id" is related to this.
Maybe some liferay staff could write some sentences to this issue.
Thanks in advance, markus
Hi Markus,
How did you convert _meetupsportlet_WAR_meetupsportlet_javax.portlet.action=SHOW_DETAILS into /SHOW_DETAILS?? I have the same problem but I can't solve this problem.
Thank you very much
12年前 に Sergey Stepanenko によって更新されました。
RE: Issues with Friendly URL and DefaultFriendlyURLMapper
Junior Member 投稿: 47 参加年月日: 10/06/01 最新の投稿
I'm also interested - can't figure out how to tranform spring action parameters. Please post .xml if possible! Thanks in advance!
12年前 に Phoenix Zerin によって更新されました。
RE: Issues with Friendly URL and DefaultFriendlyURLMapper
Junior Member 投稿: 60 参加年月日: 11/06/28 最新の投稿Eduard Saldaña:
Hi Markus,
How did you convert _meetupsportlet_WAR_meetupsportlet_javax.portlet.action=SHOW_DETAILS into /SHOW_DETAILS?? I have the same problem but I can't solve this problem.
Thank you very much
See this thread. You'll need to make sure you add <implicit-parameter name="p_p_lifecycle">1</implicit-parameter> to your routes.xml file.
12年前 に Eduard Saldaña によって更新されました。
RE: Issues with Friendly URL and DefaultFriendlyURLMapper
New Member 投稿: 19 参加年月日: 11/03/09 最新の投稿
Hi all,
We solved the problem using urlRewrite.xml located in "/ROOT/WEB-INF"
To solve the problem we map the url in xml file and then we make the links like the mapping. I attach an example below.
Where each $number is the param (.*) of the from tag.
In that way we could convert this ugly url web/guests/page?p_p_id=portletNameFront_WAR_portletNameportlet_INSTANCE_J3Wi&p_p_lifecycle=1&p_p_state=normal&p_p_mode=view&p_p_col_id=column-1&p_p_col_pos=1&p_p_col_count=2&_portletNameFront_WAR_portletNameportlet_INSTANCE_J3Wi_javax.portlet.action=actionName&parameter1=param1&parameter2=param2
to /web/guest/param1/param2/FriendlyName
Note that the last parameter is only to make the url more friendly.
We solved the problem using urlRewrite.xml located in "/ROOT/WEB-INF"
To solve the problem we map the url in xml file and then we make the links like the mapping. I attach an example below.
<rule>
<from>^/web/guest/(.*)/(.*)/(.*)$</from>
<to>/web/guests/page?p_p_id=portletNameFront_WAR_portletNameportlet_INSTANCE_J3Wi&p_p_lifecycle=1&p_p_state=normal&p_p_mode=view&p_p_col_id=column-1&p_p_col_pos=1&p_p_col_count=2&_portletNameFront_WAR_portletNameportlet_INSTANCE_J3Wi_javax.portlet.action=actionName&parameter1=$1&parameter2=$2
</to>
</rule>
Where each $number is the param (.*) of the from tag.
In that way we could convert this ugly url web/guests/page?p_p_id=portletNameFront_WAR_portletNameportlet_INSTANCE_J3Wi&p_p_lifecycle=1&p_p_state=normal&p_p_mode=view&p_p_col_id=column-1&p_p_col_pos=1&p_p_col_count=2&_portletNameFront_WAR_portletNameportlet_INSTANCE_J3Wi_javax.portlet.action=actionName&parameter1=param1&parameter2=param2
to /web/guest/param1/param2/FriendlyName
Note that the last parameter is only to make the url more friendly.
13年前 に Markus Ziller によって更新されました。
RE: Issues with Friendly URL and DefaultFriendlyURLMapper
New Member 投稿: 18 参加年月日: 10/07/14 最新の投稿Milton Waddams:
I was finally able to the routing to work (partially) for my case using the following XML<routes> <route> <pattern>/{search}</pattern> <implicit-parameter name="p_p_id">searchboxportlet_WAR_SamplePortletportlet</implicit-parameter> <implicit-parameter name="p_p_lifecycle">1</implicit-parameter> </route> </routes>
However, I'm still unable to hide the p_auth parameter. I see the "Document Library" portlet from Liferay doing it but I couldn't figure out how, any pointers there would help.
try adding
portlet.add.default.resource.check.enabled=false
auth.token.check.enabled=false
to your portal-ext.properties.
this removes the p_auth paramater from the url.
since i'm not quite sure what the effects of this on the behaving of liferay are, i'd rather look at this as a kind of workaround than as an actual solution
13年前 に Milton Waddams によって更新されました。
RE: Issues with Friendly URL and DefaultFriendlyURLMapper
New Member 投稿: 4 参加年月日: 10/10/29 最新の投稿Markus Ziller:
try addingportlet.add.default.resource.check.enabled=false auth.token.check.enabled=false
to your portal-ext.properties.
this removes the p_auth paramater from the url.
since i'm not quite sure what the effects of this on the behaving of liferay are, i'd rather look at this as a kind of workaround than as an actual solution
Thanks Markus!
I will give that a try. It should do what I need *for now*. I would also be interested to know how it affects liferay behavior and if there is a recommended alternative.
12年前 に Puj Z によって更新されました。
RE: Issues with Friendly URL and DefaultFriendlyURLMapper
Regular Member 投稿: 220 参加年月日: 10/01/14 最新の投稿
I don't think you can use friendly URLs for action URLs. At least you can't use the action name directly as one of the attributes of the URL. But I'm not 100% sure.
5年前 に Gunther Verhemeldonck によって更新されました。
RE: Issues with Friendly URL and DefaultFriendlyURLMapper
New Member 投稿: 7 参加年月日: 12/11/23 最新の投稿It is possible for sure. Just add an init-param entry to your portlet.xml to disable the p_auth token just for this single portlet.
<init-param> <name>check-auth-token</name> <value>false</value> </init-param>
For Liferay DXP add following property to your portlet:
"javax.portlet.init-param.check-auth-token=false"