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 !!!!

7 comments:

  1. Replies
    1. I am FRED and i want quickly recommend DR NCUBE for a Job well done by
      curing me from the genital herpes disease that have be giving me sleepless night. if you want to contact him, Simply do that via email drncube03@gmail.com or 
      call/whatsapp +2348155227532
      he also have #herbs for
      #hiv/aids
      #cancerdisease 
      #fibroid 
      #diabetes

      Delete
  2. hello
    I had a problem when i use tab and paging( two tabs use paging), can you help? please. thread follow
    https://www.liferay.com/zh/community/forums/-/message_boards/view_message/37578316

    ReplyDelete
  3. why It is required to use iteratorURL and set tab value in it with Search Container...... ?

    ReplyDelete
  4. When I try to pass parameters using iteratorURL it is giving error. how can I pass the parameters for the same page using iteratorURl.

    ReplyDelete
  5. this bolg is very much helpful .... I was searching for this same.. Thanks

    ReplyDelete
  6. Hi, am new to Liferay I want an idea on liferay search container..
    Liferay Search Container pagination problem.
    Am
    in 3rd page of liferay search Container. if i delete any record instead
    of going to 1st page i want to go previous page means 2nd page.. so any
    suggestion.. Am using Liferay MVC.

    ReplyDelete

nRelate Posts Only