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:-
init.jsp
Step 2:-Create view.jsp
Explanation:-
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.
search.jsp
Step 3:-Create Helper Class
Now Deploy the portlet and check the output
Output:-
1)Normal Search
2)Advance Search
You can download the source code from here.
Hope this will Help....
Related Post:-
Basic web content in Liferay
Categorization in web content
Structure and Template in Web Content
Fetch Web Content Programmatically
Get Journal Article Using SAX Parser
Form Handling in Spring Portlet
Embedding a Web Content in a Portlet
Fetch Latest Version Journal Article or Web Content in Liferay
init.jsp
Step 2:-Create view.jsp
Explanation:-
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.
search.jsp
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.
EmployeeHelper.java
EmployeeHelper.java
Now Deploy the portlet and check the output
Output:-
1)Normal Search
2)Advance Search
You can download the source code from here.
Related Post:-
Basic web content in Liferay
Categorization in web content
Structure and Template in Web Content
Fetch Web Content Programmatically
Get Journal Article Using SAX Parser
Form Handling in Spring Portlet
Embedding a Web Content in a Portlet
Fetch Latest Version Journal Article or Web Content in Liferay
No comments:
Post a Comment