Saturday, September 30, 2017

Search Form with Search Container in Liferay

In the previous tutorial on  Liferay Search Form with Search Container we see how we can search data from a search container. We override DisplayTerm and Search Container classes. Today we will create the same thing but in a simple way. Before reading this blog it is highly recommended to read my previous blog on  Liferay Search Form with Search Container.

I already created my Services using Service Builder. Here is my service.xml:-

I fill some data in Database:-

Today we apply Searching on these records on the basis of eId and eName.

Project Structure

So lets Start this step by step:-

Step 1:-Create init.jsp
First we create a init.jsp that contain all the imports:-


Step 2:-Create view.jsp
Now create view.jsp which contain our Search Container and search box:-


Here we use a simple search container which is enclosed in a aui form.For results we call methods on 3 conditions:-
1)For Advance Search
2)For Basic Search
3)For Dafault data we load all the employees.

Iterator URL is very important for pagination . If you are not using this then after search it will always redirect to first page.

Here we include a search.jsp which contain our advance search fields.


Step 3:-Create Helper Class
In view.jsp we use EmployeeHelper class to load the data.In EmployeeHelper we use dynamic query  and Conjunction , Disjunction on the basis of various scenarios like For Normal Search we use Keywords ,for Advance Search ALL operation we use Conjunction , for Advance Search ANY operation we use Disjunction etc.

Now Deploy the portlet and check the output


1)Normal Search

2)Advance Search

You can download the source code from here.

Hope this will Help....

Related Post:-

No comments:

Post a Comment

Total Pageviews

Number Of Unique Visitor

Free counters!