Foren

Please help me create friendly URL in a portlet

thumbnail
Phu Pham Cong, geändert vor 11 Jahren.

Please help me create friendly URL in a portlet

New Member Beiträge: 16 Beitrittsdatum: 30.11.10 Neueste Beiträge
Hi all,

I was tried to create friendly portletUrl follow Adding Friendly URL Mapping to the Portlet
but it does not work. plssss help me.
My code bellow:
in a liferay-portlet.xml
<friendly-url-mapper-class>com.liferay.portal.kernel.portlet.DefaultFriendlyURLMapper</friendly-url-mapper-class>
		<friendly-url-mapping>publicprofile</friendly-url-mapping>
		<friendly-url-routes>com/hvn/friendlyurl/publicprofile-friendly-url-routes.xml</friendly-url-routes>
		<instanceable>false</instanceable>


then in a publicprofile-friendly-url-routes.xml inside com.hvn.friendlyurl package
<!--?xml version="1.0"?-->

<routes>	
	<route>
		<pattern>/{jspPageName}</pattern>
		<generated-parameter name="jspPage">/html/friendlyurl/{jspPageName}.jsp</generated-parameter>
	</route>	
</routes>


view.jsp located in /html/friendlyurl
&lt;%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %&gt;

&lt;%@ page import="javax.portlet.PortletPreferences" %&gt;

<portlet:defineobjects />

&lt;%

PortletPreferences prefs = renderRequest.getPreferences();

String greeting = (String)prefs.getValue(

    "greeting", "Hello! Welcome to our portal.");

%&gt;

<p>&lt;%= greeting %&gt;</p>

<portlet:renderurl var="editGreetingURL">

    <portlet:param name="jspPage" value="/html/friendlyurl/publicprofile.jsp" />

</portlet:renderurl>

<p><a href="<%= editGreetingURL %>">Edit greeting</a></p>


then i created publicprofile.jsp located in /html/friendlyurl too
&lt;%
/**
* Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 2.1 of the License, or (at your option)
* any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*/
%&gt;
&lt;%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %&gt;

&lt;%@ taglib uri="http://liferay.com/tld/aui" prefix="aui" %&gt;

&lt;%@ page import="javax.portlet.PortletPreferences" %&gt;

<portlet:defineobjects />

&lt;%

PortletPreferences prefs = renderRequest.getPreferences();

String greeting = renderRequest.getParameter("greeting");

if (greeting != null) {    

    prefs.setValue("greeting", greeting);

    prefs.store();

%&gt;

    <p>Greeting saved successfully!</p>

&lt;%

}

%&gt;

&lt;%

greeting = (String)prefs.getValue(

    "greeting", "Hello! Welcome to our portal.");

%&gt;

<portlet:renderurl var="editGreetingURL">

    <portlet:param name="jspPage" value="/html/friendlyurl/publicprofile.jsp" />

</portlet:renderurl>

<aui:form action="<%= editGreetingURL %>" method="post">

    <aui:input label="greeting" name="greeting" type="text" value="<%= greeting %>" />

    <aui:button type="submit" />

</aui:form>

<portlet:renderurl var="viewGreetingURL">

    <portlet:param name="jspPage" value="/html/friendlyurl/view.jsp" />

</portlet:renderurl>

<p><a href="<%= viewGreetingURL %>">- Back</a></p>


When i click on Edit greeting link to render publicprofiles.jsp page. the link on address bar is: http://localhost:8080/web/guest/friendlyurl/-/publicprofile/publicprofile but it still in current page.
Can anyone help me ?

Sorry for my english emoticon
thumbnail
Tejas Kanani, geändert vor 11 Jahren.

RE: Please help me create friendly URL in a portlet

Liferay Master Beiträge: 654 Beitrittsdatum: 06.01.09 Neueste Beiträge
Any error in backlog ? Its working fine for me ..
thumbnail
Phu Pham Cong, geändert vor 11 Jahren.

RE: Please help me create friendly URL in a portlet

New Member Beiträge: 16 Beitrittsdatum: 30.11.10 Neueste Beiträge
I tried to fix in this morning. It's work fine. I think maybe mistake with naming convention in liferay-portlet.xml or in routes files.
thumbnail
Phu Pham Cong, geändert vor 11 Jahren.

RE: Please help me create friendly URL in a portlet

New Member Beiträge: 16 Beitrittsdatum: 30.11.10 Neueste Beiträge
Hi all,

when I create friendly URL for actionRequest phase. How do I remove p_auth parameter on this url? I was tried to <ignored-parameter name="p_auth"/> but still not work.
current url after making friendly look like: http://localhost:8080/web/guest/friendlyurl/-/demo/10196/action?p_auth=No0itTLv.
any idea ?
thumbnail
Phu Pham Cong, geändert vor 11 Jahren.

RE: Please help me create friendly URL in a portlet

New Member Beiträge: 16 Beitrittsdatum: 30.11.10 Neueste Beiträge
i found solutions are:
portlet.add.default.resource.check.enabled=false
auth.token.check.enabled=false


it work fine for me.
Ashraf habibi, geändert vor 11 Jahren.

RE: Please help me create friendly URL in a portlet

Junior Member Beiträge: 32 Beitrittsdatum: 13.05.11 Neueste Beiträge
How you resolve your problem....I am also facing same problem.....
Ashraf habibi, geändert vor 11 Jahren.

RE: Please help me create friendly URL in a portlet

Junior Member Beiträge: 32 Beitrittsdatum: 13.05.11 Neueste Beiträge
Ashraf habibi:
How you resolve your problem....I am also facing same problem.....


Hi

I am able to fix the problem , I am able to navigate to other page.
But I have to hard code the portletId(p_p_id) in --routes.xml like below
<implicit-parameter name="p_p_id">PaymentGateway_WAR_PaymentGatewayportlet_INSTANCE_8MaO</implicit-parameter>

With this its working fine, but the problem is here I hard code the p_p_id, which will change if you drop this portlet on other place.
When I remove this I am getting below error in the log.
ERROR [DefaultFriendlyURLMapper:252] Either p_p_id or instanceId must be provided for an instanceable portlet

How to pass this value dynamically, so that it will work properly..
Please provide your suggestion.

Thanks
Ashraf
Ashraf habibi, geändert vor 11 Jahren.

RE: Please help me create friendly URL in a portlet

Junior Member Beiträge: 32 Beitrittsdatum: 13.05.11 Neueste Beiträge
Ashraf habibi:
Ashraf habibi:
How you resolve your problem....I am also facing same problem.....


Hi

I am able to fix the problem , I am able to navigate to other page.
But I have to hard code the portletId(p_p_id) in --routes.xml like below
<implicit-parameter name="p_p_id">PaymentGateway_WAR_PaymentGatewayportlet_INSTANCE_8MaO</implicit-parameter>

With this its working fine, but the problem is here I hard code the p_p_id, which will change if you drop this portlet on other place.
When I remove this I am getting below error in the log.
ERROR [DefaultFriendlyURLMapper:252] Either p_p_id or instanceId must be provided for an instanceable portlet

How to pass this value dynamically, so that it will work properly..
Please provide your suggestion.

Thanks
Ashraf


Hi All

I resolved my above problem.
I made multi instance false <instanceable>false</instanceable>.
Before that I also did false and check it, but whenever I change it to false , my friendlyUrl is not able to generate.
Actually after changing the <instanceable>false</instanceable> value, again we have to drag & drop the portlet, then changes will reflect.

The above way I resolve my problem.

Thanks
Ashraf
Masthan Shaik, geändert vor 10 Jahren.

RE: Please help me create friendly URL in a portlet

New Member Beitrag: 1 Beitrittsdatum: 30.01.13 Neueste Beiträge
Yes , above solution worked for me as well , I am not sure why we need to put false back emoticon .. Thanks all

Cheers
Masthan
Nabil Bahtat, geändert vor 7 Jahren.

RE: Please help me create friendly URL in a portlet

New Member Beiträge: 13 Beitrittsdatum: 10.10.13 Neueste Beiträge
Hi all,
Sory about this strange request, I'm new to liferay and I wanted to use liferay polls portlet and set friendlu url using routes like explained in many wiki and docs resources in internet. Unfortunatly I did not manage to have a clean url.
Can you please help to make a polls-friendly-url-routes.xml file ?

Thanks alot.

Nabil