我用来显示我的分页结果。但是当按下下一个或上一个标签时,它会导致刷新整个页面,这是我不想要的。如何阻止页面刷新?
答案 0 :(得分:0)
使用ajax分页方法而不是普通分页
答案 1 :(得分:0)
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet"%>
<%@ taglib uri="http://liferay.com/tld/ui" prefix="liferay-ui"%>
<%@ taglib uri="http://liferay.com/tld/aui" prefix="aui" %>
<%@ page import="java.util.List"%>
<%@ page import="java.util.ArrayList" %>
<%@ page import="com.liferay.portal.kernel.util.ListUtil"%>
<%@ page import="com.liferay.portal.service.UserLocalServiceUtil"%>
<%@ page import="com.liferay.portal.model.User"%>
<%@ page import="com.liferay.portal.kernel.portlet.LiferayWindowState" %>
<%@ page import="javax.portlet.PortletURL"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<portlet:defineObjects />
<liferay-theme:defineObjects />
<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%
List<User> empList = new ArrayList<User>();
empList.addAll(UserLocalServiceUtil.getUsers(0,
UserLocalServiceUtil.getUsersCount()));
%>
<%
PortletURL renderURL = renderResponse.createRenderURL();
renderURL.setWindowState(LiferayWindowState.NORMAL);
renderURL.setParameter("jspPage","/html/userpagination/view.jsp");
%>
<liferay-ui:search-container delta="10" iteratorURL="<%= renderURL %>" emptyResultsMessage="empty-users" >
<liferay-ui:search-container-results>
<%
results=ListUtil.subList(empList,searchContainer.getStart(),searchContainer.getEnd());
total = empList.size();
pageContext.setAttribute("results", results);
pageContext.setAttribute("total", total);
%>
</liferay-ui:search-container-results>
<div class="taglib-search-iterator-page-iterator-bottom"
id="<portlet:namespace />searchUsers">
<liferay-ui:search-container-row
className="com.liferay.portal.model.User" keyProperty="userId"
modelVar="user">
<liferay-ui:search-container-column-text name="Name"
value="<%=user.getScreenName()%>" />
</liferay-ui:search-container-row>
<liferay-ui:search-iterator searchContainer="<%=searchContainer%>"
paginate="<%=false%>" />
<c:if test="<%=results.size() > 0%>">
<liferay-ui:search-paginator searchContainer="<%=searchContainer%>"
type="article" />
</c:if>
</div>
</liferay-ui:search-container>
<aui:script use="aui-io-plugin">
var searchUsers = A.one('#<portlet:namespace />searchUsers');
if (searchUsers) {
var parent = searchUsers.get('parentNode');
console.log(parent);
parent.plug(
A.Plugin.IO,
{
autoLoad: false
}
);
searchUsers.all('a').on(
'click',
function(event) {
var uri = event.currentTarget.get('href').replace(/p_p_state=normal/i, 'p_p_state=exclusive');
parent.io.set('uri', uri);
parent.io.start();
event.preventDefault();
}
);
}
</aui:script>
答案 2 :(得分:0)
这是liferay搜索容器的正常行为,因为默认情况下它不是ajaxified。 您可以尝试在JSP中设置这样的窗口模式:
<%
PortletURL portletURL = renderResponse.createRenderURL();
portletURL.setWindowState(WindowState.MAXIMIZED);
%>
致以最诚挚的问候,
丹尼尔