掲示板
URL Parameter
Hello,
i have the following navigation structure:
home (http://localhost:8080/web/guest/home)
about (http://localhost:8080/web/guest/2)
contact (http://localhost:8080/web/guest/3)
How can i add parameter to the URL ?
Example:
http://localhost:8080/web/guest/home?myParam=1
http://localhost:8080/web/guest/2?myParam=2
http://localhost:8080/web/guest/3?myParam=3&myParam4=4
Thanks
Angelika
i have the following navigation structure:
home (http://localhost:8080/web/guest/home)
about (http://localhost:8080/web/guest/2)
contact (http://localhost:8080/web/guest/3)
How can i add parameter to the URL ?
Example:
http://localhost:8080/web/guest/home?myParam=1
http://localhost:8080/web/guest/2?myParam=2
http://localhost:8080/web/guest/3?myParam=3&myParam4=4
Thanks
Angelika
Just for curiosity, is it a parameter that will be used by the portlets within the page?
I need the Parameter for URL-Rewriting with "mod_rewrite" or "UrlRewriteFilter"
I'm not entirely sure about the answer but after some quick perusal of the liferay directory it looks like the urls must be stored within the liferay database. I can't view what's within the database at the moment but that's where I'd look next. This is for Liferay 5.0 by the way.
Angelika,
mod_rewrite part of Apache HTTPD frontend, and you can 'rewrite' everything, for instance:
/15/0/M/V -> ?p_p_id=15&p_p_lifecycle=0&p_p_state=maximized&p_p_mode=view
URLRewriteFilter is for Java-based web application, it won't work with Liferay (a lot of redirects, unpredictable/random URLs/namespaces, AJAX, variable length of parameters, etc.)
Easiest plugin point to make URLs friendly: look at FriendlyURLMapper...
mod_rewrite part of Apache HTTPD frontend, and you can 'rewrite' everything, for instance:
/15/0/M/V -> ?p_p_id=15&p_p_lifecycle=0&p_p_state=maximized&p_p_mode=view
URLRewriteFilter is for Java-based web application, it won't work with Liferay (a lot of redirects, unpredictable/random URLs/namespaces, AJAX, variable length of parameters, etc.)
Easiest plugin point to make URLs friendly: look at FriendlyURLMapper...
I believe renderResponse.createRenderURL(); is the answer, and Liferay builds friendly URLs with .toString() - need to confirm... I noticed in WIKI portlet only such code, and it builds URLs like http://localhost:8080/web/test/home/wiki/Main/Child1
Yes Fuad, simply creating a portlet url and calling the .toString() method on it will result in a Friendly URL provided one is defined for the portlet in question... and also will depend on the parameters defined for the portlet URL.
i.e. it is possible for a single FriendlyURLMapper class to allow for many different mappings to a given portlet. The different mappings can be based on the phase of the portletURL (action, render, resource) and/or can be based on parameters defined.
The message board portlet provides an example of this. See MBFriendlyURLMapper.
i.e. it is possible for a single FriendlyURLMapper class to allow for many different mappings to a given portlet. The different mappings can be based on the phase of the portletURL (action, render, resource) and/or can be based on parameters defined.
The message board portlet provides an example of this. See MBFriendlyURLMapper.
Thanks Ray,
it coresponds to JSR-168, and Liferay takes care about friendlyness
But how to build friendly URL from one portlet to another portlet, such as from AssetPublisher to JournalContent (placed on same page)? I currently hardcoded it, as a sample
viewURL = articleLayoutUrl + "/" + articlePortletID + "/" + articleResource.getArticleId() + "/" + templateId;
Hope there is better solution. I know I can instantiate Journal Content with WindowState.MAXIMIZED at runtime; what if already I have an instance on a page?
it coresponds to JSR-168, and Liferay takes care about friendlyness
But how to build friendly URL from one portlet to another portlet, such as from AssetPublisher to JournalContent (placed on same page)? I currently hardcoded it, as a sample
viewURL = articleLayoutUrl + "/" + articlePortletID + "/" + articleResource.getArticleId() + "/" + templateId;
Hope there is better solution. I know I can instantiate Journal Content with WindowState.MAXIMIZED at runtime; what if already I have an instance on a page?
It has been my experience that you can send parameters like that, but by default, they are not passed to the portlets on the page.
The only way I have found that will work is if you include the portlet id and window state as parameters as well. This ends up looking something like this:
http://your.url/here?p_p_id=portletName_WAR_warFileName_INSTANCE_instanceId&p_p_state=normal&yourParam=someValue
This is not very practical, as the instance id will change every time you add a portlet to a page. Also, there is no way of knowing this without looking it up in the database first. I am currently searching for a way to get around this, but have not found it yet.
The only way I have found that will work is if you include the portlet id and window state as parameters as well. This ends up looking something like this:
http://your.url/here?p_p_id=portletName_WAR_warFileName_INSTANCE_instanceId&p_p_state=normal&yourParam=someValue
This is not very practical, as the instance id will change every time you add a portlet to a page. Also, there is no way of knowing this without looking it up in the database first. I am currently searching for a way to get around this, but have not found it yet.
15年前 に Ray Augé によって更新されました。
Re: [Liferay Forums][3. Development] RE: URL Parameter
Liferay Legend 投稿: 1197 参加年月日: 05/02/08 最新の投稿
On Fri, 2008-06-06 at 14:52 +0000, Brian Van Maurik at Liferay's
Community Forums wrote:
> This is not very practical, as the instance id will change every time
> you add a portlet to a page. Also, there is no way of knowing this
> without looking it up in the database first. I am currently searching
> for a way to get around this, but have not found it yet.
This is a limitation of the jsr-168 spec. In 5.0+ you have options such
as portlet events and shared render parameters in order to push params
to several portlets (or to portlets registering the shared params.
Also, the fact that you need the p_p_id and windows state is part of the
spec... so we're stuck with it.
Next, a very nice and clean way to pass parameters which is both spec
compliant and easy to work with is by implementing a FriendlyURLMapper
class for you portlet. This allows you to have a human readable URL and
also interprets parameters however you've formatted your URL. See for
example, the MessageBoard URLs, the Wiki URLs, Blog URLs, etc..
HTH!
----------------------------------
Raymond Augé
Software Engineer
Liferay, Inc.
Enterprise. Open Source. For Life.
----------------------------------
Liferay Meetup 2008 – Los Angeles
August 1, 2008
Meet and brainstorm with the creators of Liferay Portal, our partners
and other members of our community!
The day will consist of a series of technical sessions presented by our
integration and services partners. There is time set aside for Q&A and
corporate brainstorming to give the community a chance to give feedback
and make suggestions!
View Event Details
Register Now
Community Forums wrote:
> This is not very practical, as the instance id will change every time
> you add a portlet to a page. Also, there is no way of knowing this
> without looking it up in the database first. I am currently searching
> for a way to get around this, but have not found it yet.
This is a limitation of the jsr-168 spec. In 5.0+ you have options such
as portlet events and shared render parameters in order to push params
to several portlets (or to portlets registering the shared params.
Also, the fact that you need the p_p_id and windows state is part of the
spec... so we're stuck with it.
Next, a very nice and clean way to pass parameters which is both spec
compliant and easy to work with is by implementing a FriendlyURLMapper
class for you portlet. This allows you to have a human readable URL and
also interprets parameters however you've formatted your URL. See for
example, the MessageBoard URLs, the Wiki URLs, Blog URLs, etc..
HTH!
----------------------------------
Raymond Augé
Software Engineer
Liferay, Inc.
Enterprise. Open Source. For Life.
----------------------------------
Liferay Meetup 2008 – Los Angeles
August 1, 2008
Meet and brainstorm with the creators of Liferay Portal, our partners
and other members of our community!
The day will consist of a series of technical sessions presented by our
integration and services partners. There is time set aside for Q&A and
corporate brainstorming to give the community a chance to give feedback
and make suggestions!
View Event Details
Register Now
15年前 に Fuad Efendi によって更新されました。
RE: Re: [Liferay Forums][3. Development] RE: URL Parameter
Regular Member 投稿: 180 参加年月日: 07/04/05 最新の投稿
Hi Ray,
I am currently using FriendlyURLMapper with altered Asset Publisher & Articles; and I hardly construct those URLs (to be shown in Asset Publisher) like this:
viewURL = articleLayoutUrl + XML.encodeTitleForUrl(asset.getTitle()) + "/" + articlePortletID.substring(12) + "/" + articleResource.getArticleId();
(where 'Layout' is a page).
I think method
public String buildPath(LiferayPortletURL portletURL)
can do it much better but I don't know how to use it from JournalArticleDisplay (or another class) instance...
Thanks
I am currently using FriendlyURLMapper with altered Asset Publisher & Articles; and I hardly construct those URLs (to be shown in Asset Publisher) like this:
viewURL = articleLayoutUrl + XML.encodeTitleForUrl(asset.getTitle()) + "/" + articlePortletID.substring(12) + "/" + articleResource.getArticleId();
(where 'Layout' is a page).
I think method
public String buildPath(LiferayPortletURL portletURL)
can do it much better but I don't know how to use it from JournalArticleDisplay (or another class) instance...
Thanks
15年前 に Torsten Krah によって更新されました。
RE: Re: [Liferay Forums][3. Development] RE: URL Parameter
New Member 投稿: 4 参加年月日: 08/08/12 最新の投稿
Looking at the URL Mapper this seems a good way to do things.
But i need to use "the base friendly url" configured in the ThemeDisplay.
How can this be done?
I want to use the friendlyURL configured for this page in my URLMapper class to be portable.
Is this possible?
Or is the path build prefiexed already with the configured friendlyUrlPath from themeDisplay.
But i need to use "the base friendly url" configured in the ThemeDisplay.
How can this be done?
I want to use the friendlyURL configured for this page in my URLMapper class to be portable.
Is this possible?
Or is the path build prefiexed already with the configured friendlyUrlPath from themeDisplay.