掲示板

Please help me create friendly URL in a portlet

thumbnail
11年前 に Phu Pham Cong によって更新されました。

Please help me create friendly URL in a portlet

New Member 投稿: 16 参加年月日: 10/11/30 最新の投稿
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
11年前 に Tejas Kanani によって更新されました。

RE: Please help me create friendly URL in a portlet

Liferay Master 投稿: 654 参加年月日: 09/01/06 最新の投稿
Any error in backlog ? Its working fine for me ..
thumbnail
11年前 に Phu Pham Cong によって更新されました。

RE: Please help me create friendly URL in a portlet

New Member 投稿: 16 参加年月日: 10/11/30 最新の投稿
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
11年前 に Phu Pham Cong によって更新されました。

RE: Please help me create friendly URL in a portlet

New Member 投稿: 16 参加年月日: 10/11/30 最新の投稿
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
11年前 に Phu Pham Cong によって更新されました。

RE: Please help me create friendly URL in a portlet

New Member 投稿: 16 参加年月日: 10/11/30 最新の投稿
i found solutions are:
portlet.add.default.resource.check.enabled=false
auth.token.check.enabled=false


it work fine for me.
11年前 に Ashraf habibi によって更新されました。

RE: Please help me create friendly URL in a portlet

Junior Member 投稿: 32 参加年月日: 11/05/13 最新の投稿
How you resolve your problem....I am also facing same problem.....
11年前 に Ashraf habibi によって更新されました。

RE: Please help me create friendly URL in a portlet

Junior Member 投稿: 32 参加年月日: 11/05/13 最新の投稿
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
11年前 に Ashraf habibi によって更新されました。

RE: Please help me create friendly URL in a portlet

Junior Member 投稿: 32 参加年月日: 11/05/13 最新の投稿
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
10年前 に Masthan Shaik によって更新されました。

RE: Please help me create friendly URL in a portlet

New Member 投稿: 1 参加年月日: 13/01/30 最新の投稿
Yes , above solution worked for me as well , I am not sure why we need to put false back emoticon .. Thanks all

Cheers
Masthan
8年前 に Nabil Bahtat によって更新されました。

RE: Please help me create friendly URL in a portlet

New Member 投稿: 13 参加年月日: 13/10/10 最新の投稿
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