论坛

主页 » Liferay Portal » English » 3. Development

组合视图 统一视图 树状图
讨论主题 [ 上一个 | 下一个 ]
toggle
bougroun zineb zineb
pagination with liferay
2008年4月28日 上午9:13
答复

bougroun zineb zineb

等级: Junior Member

帖子: 36

加入日期: 2008年4月16日

最近的帖子

hi,
i want to implement a pagination using liferay
i have a table with many rows (20 rows) and I want to use a pagination.
I added this lignes in my jsp file
<%
SearchContainer searchContainer = new SearchContainer();
searchContainer.setDelta(5);
%>

<liferay-ui:search-iterator searchContainer="<%= searchContainer %>" paginate="<%= true %>" />
but i don't have a result
any idea please

thx
bougroun zineb zineb
RE: pagination with liferay
2008年4月29日 上午7:30
答复

bougroun zineb zineb

等级: Junior Member

帖子: 36

加入日期: 2008年4月16日

最近的帖子

help me pleaz
Auditya manikanta Vadrevu
RE: pagination with liferay
2008年8月19日 下午11:53
答复

Auditya manikanta Vadrevu

等级: Liferay Master

帖子: 621

加入日期: 2008年5月6日

最近的帖子

hi bougroun zineb zineb ,

i am also working for the same aspect , i have done it manually with my logic but after seeing some posts in forums i came to know that it is possible with the way liferay used. Did u got the solution , then let me know ..
khomeini syahril
RE: pagination with liferay
2009年5月6日 下午10:31
答复

khomeini syahril

等级: Junior Member

帖子: 56

加入日期: 2008年10月15日

最近的帖子

Hi Zineb
have you solved your problem? would you like to share it with me, how you make use the searchContainer?what do we have to put on the import lines?
thx
Jeffrey Paul Handa
RE: pagination with liferay
2009年5月6日 下午10:46
答复

Jeffrey Paul Handa

LIFERAY STAFF

等级: Expert

帖子: 495

加入日期: 2008年12月1日

最近的帖子

Have you tried the steps outlined in the following wiki article?

http://www.liferay.com/web/guest/community/wiki/-/wiki/Main/SearchContainer
Auditya manikanta Vadrevu
RE: pagination with liferay
2009年5月6日 下午11:44
答复

Auditya manikanta Vadrevu

等级: Liferay Master

帖子: 621

加入日期: 2008年5月6日

最近的帖子

hi all,

first i applied my own code for pagination. now i know how to use liferay pagination. here is the sample code for listing users of a particular organization.

 1
 2----
 3----
 4
 5<%
 6List headerNames = new ArrayList();
 7
 8      headerNames.add("NAME");   
 9      headerNames.add("USER PORTRAIT");   
10      headerNames.add("JOB TITLE");   
11      headerNames.add("E MAIL");   
12      headerNames.add("PHONE NUMBERS");   
13
14PortletURL portletURL = renderResponse.createRenderURL();
15portletURL.setWindowState(WindowState.MAXIMIZED);
16portletURL.setParameter("struts_action", "/results/getUsers");
17
18SearchContainer searchContainer = new SearchContainer(renderRequest, null, null, SearchContainer.DEFAULT_CUR_PARAM, SearchContainer.DEFAULT_DELTA, portletURL, headerNames, "There No Users To Display");
19
20portletURL.setParameter(searchContainer.getCurParam(), String.valueOf(searchContainer.getCurValue()));
21
22LinkedHashMap userParams = new LinkedHashMap();
23
24long orgid = 15107;
25String orgid = "15107";
26
27if(orgid == 15107)
28{
29userParams.put("usersOrg", Long.parseLong(orgid));
30
31}
32
33int nbrUser= UserLocalServiceUtil.getOrganizationUsersCount(orgid);
34
35List<User> results = UserLocalServiceUtil.search(company.getCompanyId(),null,null,[b]userParams[/b],searchContainer.getStart(),searchContainer.getEnd(),
36searchContainer.getOrderByComparator()); 
37
38
39searchContainer.setTotal(nbrUser);
40
41searchContainer.setResults(results);
42
43List resultRows = searchContainer.getResultRows();
44
45for (int i = 0; i < results.size(); i++)
46 {
47   
48        User user2 = (User)results.get(i);
49
50        ResultRow row = new ResultRow(user2, user2.getUserId(), i);
51
52        PortletURL rowURL = renderResponse.createRenderURL();
53
54        rowURL.setWindowState(WindowState.MAXIMIZED);
55
56        rowURL.setParameter("struts_action", "/results/getUsers");
57
58        rowURL.setParameter("redirect", searchContainer.getIteratorURL().toString());
59
60        rowURL.setParameter("p_u_i_d", String.valueOf(user2.getUserId()));
61
62              String firstname = user2.getFirstName();
63
64              row.addText(firstname);
65
66         /* similarly for all other details */
67
68            resultRows.add(row);
69
70}
71
72%>
73
74<liferay-ui:search-iterator searchContainer="<%= searchContainer %>" />


With Regards,
V.Auditya
srilatha etukuri
RE: pagination with liferay
2009年11月28日 上午6:12
答复

srilatha etukuri

等级: New Member

帖子: 4

加入日期: 2009年11月28日

最近的帖子

Hi Audithya,

I am using liferay5.1 and tried the approach u gave. Pagination works fine for the first page. But when i try to go to next page the content of the first page (results 1-20 etc..) is getting loaded.
Are u aware of this kind of problem?
Let me know.
Auditya manikanta Vadrevu
RE: pagination with liferay
2009年11月29日 上午3:47
答复

Auditya manikanta Vadrevu

等级: Liferay Master

帖子: 621

加入日期: 2008年5月6日

最近的帖子

hi mamatha,

there might be some error in code .

check whether searchContainer.getStart() & ....getEnd() values are are changing for the second page.

and also post your code.
srilatha etukuri
RE: pagination with liferay
2009年11月30日 上午6:14
答复

srilatha etukuri

等级: New Member

帖子: 4

加入日期: 2009年11月28日

最近的帖子

Hi,

The start and end values are not getting changed and i see them 1, 20 respectively every time.
Please find the code i am using below.

<%
List<String> headerNames = new ArrayList<String>();

headerNames.add("id");
headerNames.add("text");

PortletURL portletURL = renderResponse.createRenderURL();
portletURL.setWindowState(WindowState.MAXIMIZED);

SearchContainer searchContainer = new SearchContainer(renderRequest, null, null, SearchContainer.DEFAULT_CUR_PARAM, SearchContainer.DEFAULT_DELTA, portletURL, headerNames, "Nothing to display");
portletURL.setParameter(searchContainer.getCurParam(), String.valueOf(searchContainer.getCurValue()));

//System.out.println(" " + searchContainer.getCurParam() + " " + searchContainer.getCurValue());
//System.out.println("searchContainer.getStart() " + searchContainer.getStart() + " searchContainer.getEnd() " + searchContainer.getEnd());
List results = ListUtil.subList(allResults, searchContainer.getStart(), searchContainer.getEnd());

int total = allResults.size();
searchContainer.setTotal(total);
searchContainer.setResults(allResults);

List resultRows = searchContainer.getResultRows();

for (int i = 0; i < results.size(); i++) {
SomeObj obj = (SomeObj)results.get(i);
ResultRow row = new ResultRow(obj, obj.getId(), i);
row.addText(String.valueOf(obj.getId()));
row.addText(obj.getOriginalText());
resultRows.add(row);
}
%>

<liferay-ui:search-iterator searchContainer="<%= searchContainer %>" />
Auditya manikanta Vadrevu
RE: pagination with liferay
2009年12月1日 上午12:01
答复

Auditya manikanta Vadrevu

等级: Liferay Master

帖子: 621

加入日期: 2008年5月6日

最近的帖子

Does the page number changes ? ( getting the same results of 1 to 20 in page 2 )

first check with the whole list (allResults), it is working or not,
Mallepula NarayanaGoud
RE: pagination with liferay
2011年4月26日 上午6:57
答复

Mallepula NarayanaGoud

等级: Junior Member

帖子: 95

加入日期: 2009年6月18日

最近的帖子

Hi Srilatha etukuri,

Iam using I am using liferay5.1 and iam facing same problem.
Did you got solution?

Iam sending sample code:


<%
List<Role> rolesList = RoleUtil.findAll();



SearchContainer searchContainer = new SearchContainer();

List<String> headerNames = new ArrayList<String>();

headerNames.add("Role-id");
headerNames.add("Role-Name");
int total = rolesList.size();
searchContainer.setTotal(total);
searchContainer.setDelta(5);
searchContainer.setHeaderNames(headerNames);
searchContainer.setResults(rolesList);
searchContainer.setEmptyResultsMessage("there-are-no-live-sessions");

List resultRows = searchContainer.getResultRows();

for (int i=0; i < rolesList.size(); i++)
{
Role roles = (Role)rolesList.get(i);
String roleId = String.valueOf(roles.getRoleId());

//out.println(roles.getRoleId());
//out.println(roles.getName());

ResultRow row = new ResultRow(roles, roles.getRoleId(), i);

// RoleId
row.addText(roleId );
// RoleName
row.addText(roles.getName());
// Add result row

resultRows.add(row);
}
%>

<liferay-ui:search-iterator searchContainer="<%= searchContainer %>" paginate="true"/>
Mallepula NarayanaGoud
RE: pagination with liferay
2011年4月28日 下午9:53
答复

Mallepula NarayanaGoud

等级: Junior Member

帖子: 95

加入日期: 2009年6月18日

最近的帖子

Hi,

Now it is working fine for me......
Sample Code for it:

<%
List<Role> rolesList = RoleUtil.findAll();



PortletURL portletURL = renderResponse.createRenderURL();

SearchContainer searchContainer = new SearchContainer(renderRequest, null, null, SearchContainer.DEFAULT_CUR_PARAM, 10, portletURL, null, null);

//List<Role> birthdayUsersList = <filtered list>;

List<Role> displayList=rolesList.subList(searchContainer.getStart(), rolesList.size());

out.println("Start :" + searchContainer.getStart());
out.println("End :" + searchContainer.getEnd());
out.println("Size :"+ displayList.size());

if( searchContainer.getEnd() < rolesList.size())
{


displayList=rolesList.subList(searchContainer.getStart(), searchContainer.getEnd());
out.println("Size :"+ displayList.size());

}
searchContainer.setResults(displayList);

searchContainer.setTotal(rolesList.size());





//SearchContainer searchContainer = new SearchContainer();

List<String> headerNames = new ArrayList<String>();

headerNames.add("Role-id");
headerNames.add("Role-Name");
int total = rolesList.size();

//searchContainer.getStart();
//searchContainer.getEnd();
//searchContainer.getOrderByComparator();

//searchContainer.setTotal(total);
//searchContainer.setResults(rolesList);
//searchContainer.setDelta(5);
searchContainer.setHeaderNames(headerNames);
//searchContainer.setEmptyResultsMessage("there-are-no-live-sessions");





List resultRows = searchContainer.getResultRows();

for (int i=0; i < displayList.size(); i++)
{
Role roles = (Role)displayList.get(i);
String roleId = String.valueOf(roles.getRoleId());

//out.println(roles.getRoleId());
//out.println(roles.getName());

ResultRow row = new ResultRow(roles, roles.getRoleId(), i);

// RoleId
row.addText(roleId );
// RoleName
row.addText(roles.getName());
// Add result row

resultRows.add(row);
}
%>

<liferay-ui:search-iterator searchContainer="<%= searchContainer %>" />


Thanks,
NarayanaGoud.
Ian Michael Smith
RE: pagination with liferay
2011年4月28日 下午11:01
答复

Ian Michael Smith

等级: New Member

帖子: 1

加入日期: 2011年4月28日

最近的帖子

ok
Hari Dhanakoti
RE: pagination with liferay
2012年7月23日 上午12:55
答复

Hari Dhanakoti

等级: New Member

帖子: 14

加入日期: 2012年7月21日

最近的帖子

Am a new bie to liferay struggling for liferay pagination....
Please post the complete source code ? (jsp & java) so that i can take it up from there
Pinkesh Gandhi
RE: pagination with liferay
2012年7月23日 上午3:11
答复

Pinkesh Gandhi

等级: Regular Member

帖子: 100

加入日期: 2012年1月26日

最近的帖子

Hi Hari,

Please follow the steps mentioned in this link.
I hope it might helps you.
Dhrutika Vyas
RE: pagination with liferay
2012年7月23日 上午6:21
答复

Dhrutika Vyas

等级: Expert

帖子: 435

加入日期: 2009年2月9日

最近的帖子

Hi,

In java you need to set your searchresult list. in jsp you can write code as written below
 1<liferay-ui:search-container iteratorURL="<%=itrURL%>" delta="5" deltaConfigurable="true">
 2                   
 3       
 4                            <liferay-ui:search-container-results total="<%= list.size() %>" results="<%= ListUtil.subList(list, searchContainer.getStart(), searchContainer.getEnd()) %>" />
 5            
 6                                <liferay-ui:search-container-row className="com.test.model.SearchModel" modelVar="search" >
 7 
 8                                <h3><%=search.getTitle() %></a></h3>   
 9                                <p><%=search.getContent()%></p>
10                                </liferay-ui:search-container-row >       
11                           
12                            <liferay-ui:search-iterator searchContainer="<%= searchContainer %>" paginate="true"/>   
13                    </liferay-ui:search-container>


Regards,
Dhrutika