Wednesday, January 2, 2013

Tabs with Search Container in Liferay

Generally we have to write a lot of javascript and java code in order to deal with paging in Web based application.

But with liferay you don't have to deal with that any more. Your life become easier with liferay.

As I used to post regularly in liferay forums. I found that most of the people face issues of pagination with Tabbing.
Here I would represent how search container works with Tabs.

Below are some of the screenshot for the demo that I am going to discuss in this post.







As you will refer above screenshot, you will be able to see two tabs and both of them having list of data.
First Tab show the list of all the User Group and the Second Tab shows the list of all Users for the Current Company.

Below are the steps you need to follow :-

1) First Create the Controller Class which will extend the MVC Controller and put it's Entry in the portlet.xml.


SearchContainerController.java
2) In order to create the Tabbing View, you have to write below code in your jsp page. So in my case I have created the view.jsp and whose entry by default set in the portlet.xml.
3) As you can see in the view.jsp, there are different sections for User and UserGroup. So we have created separate pages for both of them. In order to display data related to UserGroup and User, we have created usergroup.jsp and user.jsp respectively.

usergroup.jsp

user.jsp

NOTE :- Here on the basis of  "tabs" parameter, it will return the search container.

4) In order to make the code more readable, I created the separate class for both the UserGroup i.e., UserGroupUtil and for User i.e.,UserUtil

UserGroupUtil
UserUtil
In order to work pagging in proper way for search container with different tabs. We need to create the iterator URL in proper manner. Because Pagging in Search Container works based on IteratorURL. So we need to pass proper parameter in the Iterator URL. The Below code plays an key role in the Tabbing with Search Container.
In the above code I used HashMap, because if we have more parameter to pass then we can pass easily in the Iterator URL. Hope it will be useful !!!!

nRelate Posts Only