Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Aryan sahu
liferay serach container
July 26, 2012 6:17 AM
Answer

Aryan sahu

Rank: Junior Member

Posts: 73

Join Date: July 23, 2012

Recent Posts

hi, i am trying to create a display page using the search container but it is not showing any results except showing "results page".
i have attached the code . please help me out
 1
 2
 3<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
 4<%@ taglib prefix="aui" uri="http://liferay.com/tld/aui" %>
 5<%@page import="my.services.model.Employee,my.services.service.EmployeeLocalServiceUtil" %>
 6<portlet:defineObjects />
 7
 8<h1>results page</h1>
 9
10<liferay-ui:search-container delta=4 emptyResultsMessage="no such user">
11
12
13    <liferay-ui:search-container-results
14        results="<%= EmployeeLocalServiceUtil.getbyname("hari") %>"
15
16        total="<%=EmployeeLocalServiceUtil.getEmployeesCount()%>"
17    />
18
19    <liferay-ui:search-container-row
20        className="my.services.model.Employee"
21        keyProperty="empId"
22        modelVar="data"
23    >
24        <liferay-ui:search-container-column-text
25            name="fname"
26            property="fname"
27        />
28
29        <liferay-ui:search-container-column-text
30            name="lname"
31            property="lname"
32        />
33
34       
35
36        <liferay-ui:search-container-column-jsp
37            align="right"
38            path="/html/newportlet/edit.jsp"
39        />
40    </liferay-ui:search-container-row>
41
42    <liferay-ui:search-iterator />
43</liferay-ui:search-container>
Francesco Tosco
RE: liferay serach container
July 26, 2012 7:52 AM
Answer

Francesco Tosco

Rank: New Member

Posts: 15

Join Date: October 28, 2010

Recent Posts

I think you've forgotten those two rows inside results tag:

pageContext.setAttribute("results", results);
pageContext.setAttribute("total", total);

hope this help,

bye
Harish Kumar
RE: liferay serach container
July 26, 2012 10:46 PM
Answer

Harish Kumar

Rank: Expert

Posts: 354

Join Date: July 31, 2010

Recent Posts

hi ganesh,

First of all make sure your method EmployeeLocalServiceUtil.getbyname("hari") returning any results.

Also provide start and end attribute with liferay-ui:search-container-results.

for full example please check this liferay wiki page -

http://www.liferay.com/community/wiki/-/wiki/Main/SearchContainer


Regards,
Rewati Raman
RE: liferay serach container
July 26, 2012 11:07 PM
Answer

Rewati Raman

Rank: Junior Member

Posts: 97

Join Date: February 24, 2012

Recent Posts

ganesh sahu:
hi, i am trying to create a display page using the search container but it is not showing any results except showing "results page".
i have attached the code . please help me out
 1
 2
 3<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
 4<%@ taglib prefix="aui" uri="http://liferay.com/tld/aui" %>
 5<%@page import="my.services.model.Employee,my.services.service.EmployeeLocalServiceUtil" %>
 6<portlet:defineObjects />
 7
 8<h1>results page</h1>
 9
10<liferay-ui:search-container delta=4 emptyResultsMessage="no such user">
11
12
13    <liferay-ui:search-container-results
14        results="<%= EmployeeLocalServiceUtil.getbyname("hari") %>"
15
16        total="<%=EmployeeLocalServiceUtil.getEmployeesCount()%>"
17    />
18
19    <liferay-ui:search-container-row
20        className="my.services.model.Employee"
21        keyProperty="empId"
22        modelVar="data"
23    >
24        <liferay-ui:search-container-column-text
25            name="fname"
26            property="fname"
27        />
28
29        <liferay-ui:search-container-column-text
30            name="lname"
31            property="lname"
32        />
33
34       
35
36        <liferay-ui:search-container-column-jsp
37            align="right"
38            path="/html/newportlet/edit.jsp"
39        />
40    </liferay-ui:search-container-row>
41
42    <liferay-ui:search-iterator />
43</liferay-ui:search-container>

try to use in this manner im sending my search container code
in below code my entity name is FileInfo1
 1
 2<%
 3int count = FileInfo1LocalServiceUtil.getFileInfo1sCount();
 4List<FileInfo1> books = FileInfo1LocalServiceUtil.getFileInfo1s(0, count);
 5%>
 6
 7<liferay-ui:search-container delta="2" emptyResultsMessage="no such user">
 8<liferay-ui:search-container-results>
 9<%
10results=ListUtil.subList(books,searchContainer.getStart(), searchContainer.getEnd());
11total=books.size();
12pageContext.setAttribute("results", results);
13pageContext.setAttribute("total", total); %>
14</liferay-ui:search-container-results>
15<liferay-ui:search-container-row className="com.submit.model.submit" modelVar="Submit" >
16<liferay-ui:search-container-column-text
17name="File-Name"
18property="fileName"
19/>
20<liferay-ui:search-container-column-text
21name="Sent-Date"
22property="sentDate"
23/>
24<liferay-ui:search-container-column-text
25name="Company_Name"
26property="companyName"
27/>
28</liferay-ui:search-container-row >
29</liferay-ui:search-container>


this code works for me
just try it out

Regards,
Rewati Raman
Aryan sahu
RE: liferay serach container
July 26, 2012 11:22 PM
Answer

Aryan sahu

Rank: Junior Member

Posts: 73

Join Date: July 23, 2012

Recent Posts

hey thank you it worked for me also emoticon . But i am facing a unusal situation here my delta value is 4 but its showing all the records in the same page?emoticon
Harish Kumar
RE: liferay serach container
July 26, 2012 11:35 PM
Answer

Harish Kumar

Rank: Expert

Posts: 354

Join Date: July 31, 2010

Recent Posts

Hi ganesh,

ganesh sahu:
hey thank you it worked for me also emoticon . But i am facing a unusal situation here my delta value is 4 but its showing all the records in the same page?emoticon



For Pagination you need to provide the iterator url and <liferay-ui:search-iterator /> tag

1. create renderUrl <% PortletURL iteratorURL = renderResponse.createRenderURL(); %>

2. modify the following line of code

<liferay-ui:search-container delta="2" emptyResultsMessage="no such user" iteratorURL="<%=iteratorURL%>">

3. Add the <liferay-ui:search-iterator /> tag

</liferay-ui:search-container-row>
<liferay-ui:search-iterator />
</liferay-ui:search-container>

Regards
Jignesh Vachhani
RE: liferay serach container
July 27, 2012 4:50 AM
Answer

Jignesh Vachhani

Rank: Liferay Master

Posts: 780

Join Date: March 10, 2008

Recent Posts

you can check working code on : http://www.liferaysolution.com/2012/07/pagination-in-liferay-61.html
Rewati Raman
RE: liferay serach container
July 27, 2012 8:02 AM
Answer

Rewati Raman

Rank: Junior Member

Posts: 97

Join Date: February 24, 2012

Recent Posts

yes that is it correct....Harish

while editing the code by mistake I had removed that tag

sorry for that..

Regards,
Rewati Raman