Foren

Home » Liferay Portal » English » 3. Development

Kombinierte Ansicht Flache Ansicht Baumansicht
Threads [ Zurück | Nächste ]
toggle
Sunil Kulkarni
Appending the parameter to community home page URL
16. Januar 2013 01:25
Antwort

Sunil Kulkarni

Rang: Junior Member

Nachrichten: 88

Eintrittsdatum: 24. Juni 2011

Neue Beiträge

Hello All,

I have done following :
1. I have created open community named with 'bookshelf'. This community having only one page with layout 1 column.
2. I have create a portlet 'Books' and I have deployed that portlet on home page of the 'bookshelf' community. This book portlet having category wise data.

Now, the friendly url generated for the community 'bookshelf' is http://localhost:8080/web/bookshelf/home. So when any user directly copy and paste this URL in the browser, he can see the 'books' portlet.

Now I am achieving following:
Any user can give the category as parameter to the books portlet so that according to the parameter the book portlet will display the listing of the books.
e.g. If I typed http://localhost:8080/web/bookshelf/home?category=technical then book portlet should display the listing of books for category technical and if I typed http://localhost:8080/web/bookshelf/home?category=medical then book portlet should display the listing for medical category.

My question is :
Is this a valid way to pass this category parameter as mentioned above. In liferay, we are not directly appending the parameter as mentioned above.

Any thoughts will be very helpful.
Sunil Kulkarni
RE: Appending the parameter to community home page URL(Resolved)
19. Januar 2013 04:02
Antwort

Sunil Kulkarni

Rang: Junior Member

Nachrichten: 88

Eintrittsdatum: 24. Juni 2011

Neue Beiträge

I have resoved this issue using portlet friendly URL.

I did the following :
1. Created a bookshelf.xml for friendly url
it contains following:
1     <routes>
2          <route>
3    <pattern>/{categoryName}</pattern>
4    <generated-parameter name="categoryName">{categoryName}</generated-parameter>
5          </route>
6      </routes>

2. Added the following in liferay-portlet.xml
1     <friendly-url-mapper-class>com.liferay.portal.kernel.portlet.DefaultFriendlyURLMapper</friendly-url-mapper-class>
2     <friendly-url-mapping>bookshelf</friendly-url-mapping>
3     <friendly-url-routes>bookshelf.xml</friendly-url-routes>


3. Now my friendly URL is http://localhost:8080/web/bookshelf/home/-/bookshelf/technical

4. I can access categoryName in my portlet using
1String categoryName = ParamUtil.get(request, "categoryName", "");
Praveen Motamarri
RE: Appending the parameter to community home page URL
1. Februar 2013 06:06
Antwort

Praveen Motamarri

Rang: New Member

Nachrichten: 1

Eintrittsdatum: 4. Februar 2010

Neue Beiträge

You can retrieve the parameter in the jsp like this
String category = PortalUtil.getOriginalServletRequest(request).getParameter("category");