Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Problems with Freidnly URL and calling Actions Stefan Petrushevski May 27, 2014 6:56 AM
RE: Problems with Freidnly URL and calling Actions Bijan Vakili May 27, 2014 9:35 AM
RE: Problems with Freidnly URL and calling Actions Stefan Petrushevski May 27, 2014 1:01 PM
RE: Problems with Freidnly URL and calling Actions Tina Agrawal May 28, 2014 12:42 AM
RE: Problems with Freidnly URL and calling Actions Tina Agrawal May 28, 2014 12:43 AM
RE: Problems with Freidnly URL and calling Actions Stefan Petrushevski May 29, 2014 6:17 AM
RE: Problems with Freidnly URL and calling Actions Andrew Jardine May 29, 2014 3:15 PM
RE: Problems with Freidnly URL and calling Actions Stefan Petrushevski May 30, 2014 3:29 AM
RE: Problems with Freidnly URL and calling Actions Andrew Jardine May 30, 2014 1:33 PM
RE: Problems with Freidnly URL and calling Actions Stefan Petrushevski June 2, 2014 5:47 AM
RE: Problems with Freidnly URL and calling Actions Andrew Jardine June 5, 2014 2:52 PM
RE: Problems with Freidnly URL and calling Actions Stefan Petrushevski June 10, 2014 8:42 AM
RE: Problems with Freidnly URL and calling Actions Andrew Jardine June 11, 2014 2:44 PM
RE: Problems with Freidnly URL and calling Actions Stefan Petrushevski June 13, 2014 4:08 AM
RE: Problems with Freidnly URL and calling Actions Andrew Jardine June 13, 2014 8:49 AM
RE: Problems with Freidnly URL and calling Actions Stefan Petrushevski June 16, 2014 3:58 AM
RE: Problems with Freidnly URL and calling Actions Meera Prince June 18, 2014 7:10 PM
RE: Problems with Freidnly URL and calling Actions Andrew Jardine June 18, 2014 1:27 PM
RE: Problems with Freidnly URL and calling Actions Stefan Petrushevski June 23, 2014 2:19 AM
RE: Problems with Freidnly URL and calling Actions Stefan Petrushevski June 24, 2014 3:18 AM
RE: Problems with Freidnly URL and calling Actions Stefan Petrushevski June 24, 2014 2:02 PM
RE: Problems with Freidnly URL and calling Actions Bijan Vakili May 29, 2014 10:55 AM
Stefan Petrushevski
Problems with Freidnly URL and calling Actions
May 27, 2014 6:56 AM
Answer

Stefan Petrushevski

Rank: New Member

Posts: 13

Join Date: April 28, 2014

Recent Posts

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
Bijan Vakili
RE: Problems with Freidnly URL and calling Actions
May 27, 2014 9:35 AM
Answer

Bijan Vakili

Rank: Expert

Posts: 354

Join Date: March 10, 2009

Recent Posts

Shouldn't you have parameter like this?
"javax.portlet.action" and not "action"?
Stefan Petrushevski
RE: Problems with Freidnly URL and calling Actions
May 27, 2014 1:01 PM
Answer

Stefan Petrushevski

Rank: New Member

Posts: 13

Join Date: April 28, 2014

Recent Posts

Tried that too... Didn't help.
Tina Agrawal
RE: Problems with Freidnly URL and calling Actions
May 28, 2014 12:42 AM
Answer

Tina Agrawal

Rank: Expert

Posts: 294

Join Date: January 2, 2008

Recent Posts

Can you try this -

1<portlet:actionURL var="opentopicURL" name="openTopic">
2    <portlet:param name="topicId" value="<%= t.getId().toString() %>" />
3 </portlet:actionURL>


Tina
Tina Agrawal
RE: Problems with Freidnly URL and calling Actions
May 28, 2014 12:43 AM
Answer

Tina Agrawal

Rank: Expert

Posts: 294

Join Date: January 2, 2008

Recent Posts

Also make sure you dont have a processAction method in your class.

Tina
Stefan Petrushevski
RE: Problems with Freidnly URL and calling Actions
May 29, 2014 6:17 AM
Answer

Stefan Petrushevski

Rank: New Member

Posts: 13

Join Date: April 28, 2014

Recent Posts

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.
Bijan Vakili
RE: Problems with Freidnly URL and calling Actions
May 29, 2014 10:55 AM
Answer

Bijan Vakili

Rank: Expert

Posts: 354

Join Date: March 10, 2009

Recent Posts

Just to be sure, it works without the route? And when add route, the issue occurs, right?
Andrew Jardine
RE: Problems with Freidnly URL and calling Actions
May 29, 2014 3:15 PM
Answer

Andrew Jardine

Community Moderator

Rank: Liferay Legend

Posts: 1062

Join Date: December 22, 2010

Recent Posts

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.
Stefan Petrushevski
RE: Problems with Freidnly URL and calling Actions
May 30, 2014 3:29 AM
Answer

Stefan Petrushevski

Rank: New Member

Posts: 13

Join Date: April 28, 2014

Recent Posts

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.
Andrew Jardine
RE: Problems with Freidnly URL and calling Actions
May 30, 2014 1:33 PM
Answer

Andrew Jardine

Community Moderator

Rank: Liferay Legend

Posts: 1062

Join Date: December 22, 2010

Recent Posts

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
RE: Problems with Freidnly URL and calling Actions
June 2, 2014 5:47 AM
Answer

Stefan Petrushevski

Rank: New Member

Posts: 13

Join Date: April 28, 2014

Recent Posts

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.
1
2    @Override
3    public void processAction(ActionRequest actionRequest, ActionResponse actionResponse) throws java.io.IOException, javax.portlet.PortletException{
4        System.out.println("ZZZ in Action!");
5    }


Any ideas why is this happening? Maybe I need to make changes to the default FriendlyURL class?
Andrew Jardine
RE: Problems with Freidnly URL and calling Actions
June 5, 2014 2:52 PM
Answer

Andrew Jardine

Community Moderator

Rank: Liferay Legend

Posts: 1062

Join Date: December 22, 2010

Recent Posts

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?
Stefan Petrushevski
RE: Problems with Freidnly URL and calling Actions
June 10, 2014 8:42 AM
Answer

Stefan Petrushevski

Rank: New Member

Posts: 13

Join Date: April 28, 2014

Recent Posts

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) emoticon

Sorry for the late reply.
Andrew Jardine
RE: Problems with Freidnly URL and calling Actions
June 11, 2014 2:44 PM
Answer

Andrew Jardine

Community Moderator

Rank: Liferay Legend

Posts: 1062

Join Date: December 22, 2010

Recent Posts

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.
Stefan Petrushevski
RE: Problems with Freidnly URL and calling Actions
June 13, 2014 4:08 AM
Answer

Stefan Petrushevski

Rank: New Member

Posts: 13

Join Date: April 28, 2014

Recent Posts

Here are the details:
 1
 2
 3before:
 4http://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
 5----
 6    liferay-portal.xml
 7    <friendly-url-mapper-class>
 8    com.liferay.portal.kernel.portlet.DefaultFriendlyURLMapper
 9    </friendly-url-mapper-class>
10    <friendly-url-mapping>
11        help-support
12    </friendly-url-mapping>
13    <friendly-url-routes>
14        com/iwmn/egain/portlets/egain-portlet-friendly-url-routes.xml
15    </friendly-url-routes>
16----
17    route:
18    <route>
19        <pattern>/topic/{topicId:\d+}/</pattern>
20        <implicit-parameter name="p_p_lifecycle">1</implicit-parameter>
21        <implicit-parameter name="javax.portlet.action">openTopic</implicit-parameter>
22    </route>
23-----   
24    jsp:
25    ...
26    <portlet:actionURL name="openArticle" var="OpenArticleURL">
27        <portlet:param name="articleId" value="<%= a.getId().toString() %>" />
28    </portlet:actionURL>
29    <li><a href="${OpenArticleURL}"><%=a.getName() %></a></li>
30    ...
31----
32after:
33http://dwww.vip.mk/testing/-/help-support/topic/1338/
Andrew Jardine
RE: Problems with Freidnly URL and calling Actions
June 13, 2014 8:49 AM
Answer

Andrew Jardine

Community Moderator

Rank: Liferay Legend

Posts: 1062

Join Date: December 22, 2010

Recent Posts

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?
Stefan Petrushevski
RE: Problems with Freidnly URL and calling Actions
June 16, 2014 3:58 AM
Answer

Stefan Petrushevski

Rank: New Member

Posts: 13

Join Date: April 28, 2014

Recent Posts

I changed the rule as you suggested and now the links are not matched to it:
1
2    <route>
3        <pattern>/topic/{topicId:\d+}/</pattern>
4        <implicit-parameter name="p_p_lifecycle">1</implicit-parameter>
5        <implicit-parameter name="_eGain_WAR_Egainportlet_javax.portlet.action">openTopic</implicit-parameter>
6    </route>
Andrew Jardine
RE: Problems with Freidnly URL and calling Actions
June 18, 2014 1:27 PM
Answer

Andrew Jardine

Community Moderator

Rank: Liferay Legend

Posts: 1062

Join Date: December 22, 2010

Recent Posts

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?
Meera Prince
RE: Problems with Freidnly URL and calling Actions
June 18, 2014 7:10 PM
Answer

Meera Prince

Rank: Liferay Legend

Posts: 1110

Join Date: February 8, 2011

Recent Posts

HI
Have a look into following article it may help you..

http://www.liferaysavvy.com/2014/06/liferay-friendly-url.html


Regards,
Meera Prince
Stefan Petrushevski
RE: Problems with Freidnly URL and calling Actions
June 23, 2014 2:19 AM
Answer

Stefan Petrushevski

Rank: New Member

Posts: 13

Join Date: April 28, 2014

Recent Posts

Andew 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
RE: Problems with Freidnly URL and calling Actions
June 24, 2014 3:18 AM
Answer

Stefan Petrushevski

Rank: New Member

Posts: 13

Join Date: April 28, 2014

Recent Posts

Andew Jardine had the time and nerves to go over this again in great detail and we finally have a solution emoticon. Tnx Andrew!

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
RE: Problems with Freidnly URL and calling Actions
June 24, 2014 2:02 PM
Answer

Stefan Petrushevski

Rank: New Member

Posts: 13

Join Date: April 28, 2014

Recent Posts

The issue was the actual variable name 'topicId'. I switched it do 'tId' and the pattern works fine now.

1
2    <route>
3        <pattern>/topic/{tId:\d+}</pattern>
4        <implicit-parameter name="javax.portlet.action">openTopic</implicit-parameter>
5        <implicit-parameter name="p_p_lifecycle">1</implicit-parameter>
6    </route>