掲示板

URL Parameter

15年前 に Angelika Morgan によって更新されました。

URL Parameter

New Member 投稿: 23 参加年月日: 07/08/27 最新の投稿
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
15年前 に Aaron A'brook によって更新されました。

RE: URL Parameter

New Member 投稿: 8 参加年月日: 08/05/19 最新の投稿
Just for curiosity, is it a parameter that will be used by the portlets within the page?
15年前 に Angelika Morgan によって更新されました。

RE: URL Parameter

New Member 投稿: 23 参加年月日: 07/08/27 最新の投稿
I need the Parameter for URL-Rewriting with "mod_rewrite" or "UrlRewriteFilter"
15年前 に Aaron A'brook によって更新されました。

RE: URL Parameter

New Member 投稿: 8 参加年月日: 08/05/19 最新の投稿
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.
thumbnail
15年前 に Fuad Efendi によって更新されました。

RE: URL Parameter

Regular Member 投稿: 180 参加年月日: 07/04/05 最新の投稿
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...
thumbnail
15年前 に Fuad Efendi によって更新されました。

RE: URL Parameter

Regular Member 投稿: 180 参加年月日: 07/04/05 最新の投稿
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
thumbnail
15年前 に Ray Augé によって更新されました。

RE: URL Parameter

Liferay Legend 投稿: 1197 参加年月日: 05/02/08 最新の投稿
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.
thumbnail
15年前 に Fuad Efendi によって更新されました。

RE: URL Parameter

Regular Member 投稿: 180 参加年月日: 07/04/05 最新の投稿
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?
15年前 に Brian Van Maurik によって更新されました。

RE: URL Parameter

New Member 投稿: 14 参加年月日: 07/07/12 最新の投稿
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.
thumbnail
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
thumbnail
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
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.