留言板
pagination with liferay
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
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
auditya manikanta vadrevu,修改在15 年前。
RE: pagination with liferay
Liferay Master 帖子: 621 加入日期: 08-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 ..
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 ..
Auditya manikanta Vadrevu,修改在14 年前。
RE: pagination with liferay
Liferay Master 帖子: 621 加入日期: 08-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.
With Regards,
V.Auditya
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.
----
----
<%
List headerNames = new ArrayList();
headerNames.add("NAME");
headerNames.add("USER PORTRAIT");
headerNames.add("JOB TITLE");
headerNames.add("E MAIL");
headerNames.add("PHONE NUMBERS");
PortletURL portletURL = renderResponse.createRenderURL();
portletURL.setWindowState(WindowState.MAXIMIZED);
portletURL.setParameter("struts_action", "/results/getUsers");
SearchContainer searchContainer = new SearchContainer(renderRequest, null, null, SearchContainer.DEFAULT_CUR_PARAM, SearchContainer.DEFAULT_DELTA, portletURL, headerNames, "There No Users To Display");
portletURL.setParameter(searchContainer.getCurParam(), String.valueOf(searchContainer.getCurValue()));
LinkedHashMap userParams = new LinkedHashMap();
long orgid = 15107;
String orgid = "15107";
if(orgid == 15107)
{
userParams.put("usersOrg", Long.parseLong(orgid));
}
int nbrUser= UserLocalServiceUtil.getOrganizationUsersCount(orgid);
List<user> results = UserLocalServiceUtil.search(company.getCompanyId(),null,null,[b]userParams[/b],searchContainer.getStart(),searchContainer.getEnd(),
searchContainer.getOrderByComparator());
searchContainer.setTotal(nbrUser);
searchContainer.setResults(results);
List resultRows = searchContainer.getResultRows();
for (int i = 0; i < results.size(); i++)
{
User user2 = (User)results.get(i);
ResultRow row = new ResultRow(user2, user2.getUserId(), i);
PortletURL rowURL = renderResponse.createRenderURL();
rowURL.setWindowState(WindowState.MAXIMIZED);
rowURL.setParameter("struts_action", "/results/getUsers");
rowURL.setParameter("redirect", searchContainer.getIteratorURL().toString());
rowURL.setParameter("p_u_i_d", String.valueOf(user2.getUserId()));
String firstname = user2.getFirstName();
row.addText(firstname);
/* similarly for all other details */
resultRows.add(row);
}
%>
<liferay-ui:search-iterator searchContainer="<%= searchContainer %>" />
</user>
With Regards,
V.Auditya
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.
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,修改在14 年前。
RE: pagination with liferay
Liferay Master 帖子: 621 加入日期: 08-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.
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.
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 %>" />
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,修改在14 年前。
RE: pagination with liferay
Liferay Master 帖子: 621 加入日期: 08-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,
first check with the whole list (allResults), it is working or not,
Mallepula NarayanaGoud,修改在12 年前。
RE: pagination with liferay
Junior Member 帖子: 95 加入日期: 09-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"/>
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,修改在12 年前。
RE: pagination with liferay
Junior Member 帖子: 95 加入日期: 09-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.
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.
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
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
ok
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
Please post the complete source code ? (jsp & java) so that i can take it up from there
Hi,
In java you need to set your searchresult list. in jsp you can write code as written below
Regards,
Dhrutika
In java you need to set your searchresult list. in jsp you can write code as written below
<liferay-ui:search-container iteratorurl="<%=itrURL%>" delta="5" deltaconfigurable="true">
<liferay-ui:search-container-results total="<%= list.size() %>" results="<%= ListUtil.subList(list, searchContainer.getStart(), searchContainer.getEnd()) %>" />
<liferay-ui:search-container-row classname="com.test.model.SearchModel" modelvar="search">
<h3><%=search.getTitle() %></h3>
<p><%=search.getContent()%></p>
</liferay-ui:search-container-row>
<liferay-ui:search-iterator searchContainer="<%= searchContainer %>" paginate="true" />
</liferay-ui:search-container>
Regards,
Dhrutika