Forums de discussion
Problems with Freidnly URL and calling Actions
Stefan Petrushevski, modifié il y a 9 années.
Problems with Freidnly URL and calling Actions
New Member Publications: 13 Date d'inscription: 28/04/14 Publications récentes
Hello... I'm having issues with mapping friendly URL action to a method in the controller.
The route is recognized and the friendly url is 'built' right. I can see the friendly url in browser as http://.../help_support/-/topic/N, but when i click it, the method is the MVCPortlet class is not called.
Here is the route, the jsp part and the method in my MVC class:
http://pastebin.com/cAH0VrKb
The route is recognized and the friendly url is 'built' right. I can see the friendly url in browser as http://.../help_support/-/topic/N, but when i click it, the method is the MVCPortlet class is not called.
Here is the route, the jsp part and the method in my MVC class:
http://pastebin.com/cAH0VrKb
Bijan Vakili, modifié il y a 9 années.
RE: Problems with Freidnly URL and calling Actions
Expert Publications: 375 Date d'inscription: 10/03/09 Publications récentes
Shouldn't you have parameter like this?
"javax.portlet.action" and not "action"?
"javax.portlet.action" and not "action"?
Stefan Petrushevski, modifié il y a 9 années.
RE: Problems with Freidnly URL and calling Actions
New Member Publications: 13 Date d'inscription: 28/04/14 Publications récentes
Tried that too... Didn't help.
Tina Agrawal, modifié il y a 9 années.
RE: Problems with Freidnly URL and calling Actions
Expert Publications: 297 Date d'inscription: 03/01/08 Publications récentes
Can you try this -
Tina
<portlet:actionurl var="opentopicURL" name="openTopic">
<portlet:param name="topicId" value="<%= t.getId().toString() %>" />
</portlet:actionurl>
Tina
Tina Agrawal, modifié il y a 9 années.
RE: Problems with Freidnly URL and calling Actions
Expert Publications: 297 Date d'inscription: 03/01/08 Publications récentes
Also make sure you dont have a processAction method in your class.
Tina
Tina
Stefan Petrushevski, modifié il y a 9 années.
RE: Problems with Freidnly URL and calling Actions
New Member Publications: 13 Date d'inscription: 28/04/14 Publications récentes
What do you mean? But I want to have action method in my portlet class to handle the request.
I'm done with the portlet class and the methods. Everything works fine, I now want to introduce friendly URLs.
I'm done with the portlet class and the methods. Everything works fine, I now want to introduce friendly URLs.
Andew Jardine, modifié il y a 9 années.
RE: Problems with Freidnly URL and calling Actions
Liferay Legend Publications: 2416 Date d'inscription: 22/12/10 Publications récentes
I have done something similar but my code is slightly different then yours. Based on the pastebin... try these changes.
<route>
<pattern>/topic/{topicId:\d+}/</pattern>
<implicit-parameter name="p_p_lifecycle">1</implicit-parameter>
<implicit-parameter name="javax.portlet.action">openTopic</implicit-parameter>
</route>
<portlet:actionURL var="opentopicURL" name="openTopic">
<portlet:param name="topicId" value="<%= t.getId().toString() %>" />
</portlet:actionURL>
@ProcessAction(name="openTopic")
public void openTopic(ActionRequest request, ActionResponse response) throws Exception {
System.out.println("IN ACTION");
}
That worked for me.
<route>
<pattern>/topic/{topicId:\d+}/</pattern>
<implicit-parameter name="p_p_lifecycle">1</implicit-parameter>
<implicit-parameter name="javax.portlet.action">openTopic</implicit-parameter>
</route>
<portlet:actionURL var="opentopicURL" name="openTopic">
<portlet:param name="topicId" value="<%= t.getId().toString() %>" />
</portlet:actionURL>
@ProcessAction(name="openTopic")
public void openTopic(ActionRequest request, ActionResponse response) throws Exception {
System.out.println("IN ACTION");
}
That worked for me.
Stefan Petrushevski, modifié il y a 9 années.
RE: Problems with Freidnly URL and calling Actions
New Member Publications: 13 Date d'inscription: 28/04/14 Publications récentes
Thanks for the suggestion but this didn't help either.
I still get the rule matched and the links display with friendly URL but the action method in the portlet is not being fired.
I still get the rule matched and the links display with friendly URL but the action method in the portlet is not being fired.
Andew Jardine, modifié il y a 9 années.
RE: Problems with Freidnly URL and calling Actions
Liferay Legend Publications: 2416 Date d'inscription: 22/12/10 Publications récentes
Suggestion. In your portlet class, override the doAction method and add a logging statement to see if it is getting there. That should at least tell you whether or not you are actually invoking an action (that maybe the annotation is messed up) or if you are going straight to the render phase?
Stefan Petrushevski, modifié il y a 9 années.
RE: Problems with Freidnly URL and calling Actions
New Member Publications: 13 Date d'inscription: 28/04/14 Publications récentes
I overrode processAction and no, the Action matched by the FriendlyURL route is not firing action method (processAction) meaning it goes straight to render phase.
Any ideas why is this happening? Maybe I need to make changes to the default FriendlyURL class?
@Override
public void processAction(ActionRequest actionRequest, ActionResponse actionResponse) throws java.io.IOException, javax.portlet.PortletException{
System.out.println("ZZZ in Action!");
}
Any ideas why is this happening? Maybe I need to make changes to the default FriendlyURL class?
Andew Jardine, modifié il y a 9 années.
RE: Problems with Freidnly URL and calling Actions
Liferay Legend Publications: 2416 Date d'inscription: 22/12/10 Publications récentes
Stefan,
Apologies, the week got away from me. Are yo ustill struggling with this? If you are, can you send the url you are using again?
Also, if you remove the friendly URL configuration, does your action method fire?
Apologies, the week got away from me. Are yo ustill struggling with this? If you are, can you send the url you are using again?
Also, if you remove the friendly URL configuration, does your action method fire?
Stefan Petrushevski, modifié il y a 9 années.
RE: Problems with Freidnly URL and calling Actions
New Member Publications: 13 Date d'inscription: 28/04/14 Publications récentes
Yes the methods work fine without friendlyURL. Apparently when I add the routes and they are matched, the action method is not fired.
I can't share the URL, it's private one. (If that's what you meant)
Sorry for the late reply.
I can't share the URL, it's private one. (If that's what you meant)
Sorry for the late reply.
Andew Jardine, modifié il y a 9 années.
RE: Problems with Freidnly URL and calling Actions
Liferay Legend Publications: 2416 Date d'inscription: 22/12/10 Publications récentes
Hey Stefan,
I didn't mean for me to go to the site or anything, I just mean to copy and paste the URL in here... delete the domain and port if you like. Also, it occurred to me that I once had a problem like this where I made the mistake and set the method type "GET" on the form which doesn't fire the actions. But since you have no issue when the Friendly URL is disabled, I am guessing that is not it.
If you can share with me the url (minus the domain and port) I can try to reproduce on my side.
I didn't mean for me to go to the site or anything, I just mean to copy and paste the URL in here... delete the domain and port if you like. Also, it occurred to me that I once had a problem like this where I made the mistake and set the method type "GET" on the form which doesn't fire the actions. But since you have no issue when the Friendly URL is disabled, I am guessing that is not it.
If you can share with me the url (minus the domain and port) I can try to reproduce on my side.
Stefan Petrushevski, modifié il y a 9 années.
RE: Problems with Freidnly URL and calling Actions
New Member Publications: 13 Date d'inscription: 28/04/14 Publications récentes
Here are the details:
before:
http://ws/testing?p_p_id=eGain_WAR_Egainportlet&p_p_lifecycle=1&p_p_state=normal&p_p_mode=view&p_p_col_id=column-1&p_p_col_count=1&_eGain_WAR_Egainportlet_topicId=1338&_eGain_WAR_Egainportlet_javax.portlet.action=openTopic
----
liferay-portal.xml
<friendly-url-mapper-class>
com.liferay.portal.kernel.portlet.DefaultFriendlyURLMapper
</friendly-url-mapper-class>
<friendly-url-mapping>
help-support
</friendly-url-mapping>
<friendly-url-routes>
com/iwmn/egain/portlets/egain-portlet-friendly-url-routes.xml
</friendly-url-routes>
----
route:
<route>
<pattern>/topic/{topicId:\d+}/</pattern>
<implicit-parameter name="p_p_lifecycle">1</implicit-parameter>
<implicit-parameter name="javax.portlet.action">openTopic</implicit-parameter>
</route>
-----
jsp:
...
<portlet:actionurl name="openArticle" var="OpenArticleURL">
<portlet:param name="articleId" value="<%= a.getId().toString() %>" />
</portlet:actionurl>
<li><a href="${OpenArticleURL}"><%=a.getName() %></a></li>
...
----
after:
http://dwww.vip.mk/testing/-/help-support/topic/1338/
Andew Jardine, modifié il y a 9 années.
RE: Problems with Freidnly URL and calling Actions
Liferay Legend Publications: 2416 Date d'inscription: 22/12/10 Publications récentes
Just replied on the IRC channel, but can you try using
_eGain_WAR_Egainportlet_javax.portlet.action
for your implicit action mapping in the route file?
_eGain_WAR_Egainportlet_javax.portlet.action
for your implicit action mapping in the route file?
Stefan Petrushevski, modifié il y a 9 années.
RE: Problems with Freidnly URL and calling Actions
New Member Publications: 13 Date d'inscription: 28/04/14 Publications récentes
I changed the rule as you suggested and now the links are not matched to it:
<route>
<pattern>/topic/{topicId:\d+}/</pattern>
<implicit-parameter name="p_p_lifecycle">1</implicit-parameter>
<implicit-parameter name="_eGain_WAR_Egainportlet_javax.portlet.action">openTopic</implicit-parameter>
</route>
Meera Prince, modifié il y a 9 années.
RE: Problems with Freidnly URL and calling Actions
Liferay Legend Publications: 1111 Date d'inscription: 08/02/11 Publications récentes
HI
Have a look into following article it may help you..
http://www.liferaysavvy.com/2014/06/liferay-friendly-url.html
Regards,
Meera Prince
Have a look into following article it may help you..
http://www.liferaysavvy.com/2014/06/liferay-friendly-url.html
Regards,
Meera Prince
Andew Jardine, modifié il y a 9 années.
RE: Problems with Freidnly URL and calling Actions
Liferay Legend Publications: 2416 Date d'inscription: 22/12/10 Publications récentes
you action url has a name of "openArticle" but your mapping is using "openTopic" -- was that just a typo? or are these out of synch?
Stefan Petrushevski, modifié il y a 9 années.
RE: Problems with Freidnly URL and calling Actions
New Member Publications: 13 Date d'inscription: 28/04/14 Publications récentesAndew Jardine:
you action url has a name of "openArticle" but your mapping is using "openTopic" -- was that just a typo? or are these out of synch?
Yes ... it's a typo. I have the openTopic method defined in my portlet class and using that name in my jsp page..
Stefan Petrushevski, modifié il y a 9 années.
RE: Problems with Freidnly URL and calling Actions
New Member Publications: 13 Date d'inscription: 28/04/14 Publications récentes
Andew Jardine had the time and nerves to go over this again in great detail and we finally have a solution . Tnx Andrew!
The route that works is:
The whole issue was the \d+ in the pattern <pattern>/topic/{topicId:\d+}</pattern>. Anyone has idea why?
The route that works is:
<route>
<pattern>/topic/{topicId}</pattern>
<implicit-parameter name="javax.portlet.action">openTopic</implicit-parameter>
<implicit-parameter name="p_p_lifecycle">1</implicit-parameter>
</route>
The whole issue was the \d+ in the pattern <pattern>/topic/{topicId:\d+}</pattern>. Anyone has idea why?
Stefan Petrushevski, modifié il y a 9 années.
RE: Problems with Freidnly URL and calling Actions
New Member Publications: 13 Date d'inscription: 28/04/14 Publications récentes
The issue was the actual variable name 'topicId'. I switched it do 'tId' and the pattern works fine now.
<route>
<pattern>/topic/{tId:\d+}</pattern>
<implicit-parameter name="javax.portlet.action">openTopic</implicit-parameter>
<implicit-parameter name="p_p_lifecycle">1</implicit-parameter>
</route>
Bijan Vakili, modifié il y a 9 années.
RE: Problems with Freidnly URL and calling Actions
Expert Publications: 375 Date d'inscription: 10/03/09 Publications récentes
Just to be sure, it works without the route? And when add route, the issue occurs, right?