Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Sunil Kulkarni
Appending the parameter to community home page URL
January 16, 2013 1:25 AM
Answer

Sunil Kulkarni

Rank: Junior Member

Posts: 94

Join Date: June 24, 2011

Recent Posts

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)
January 19, 2013 4:02 AM
Answer

Sunil Kulkarni

Rank: Junior Member

Posts: 94

Join Date: June 24, 2011

Recent Posts

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
February 1, 2013 6:06 AM
Answer

Praveen Motamarri

Rank: New Member

Posts: 1

Join Date: February 4, 2010

Recent Posts

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