我在Liferay 6.2中使用Service builder创建了一个primefaces portlet,但是我有一个问题。我需要具有分页的组件数据表,但它不起作用。这是我的观点代码:
<?xml version="1.0"?>
<f:view xmlns="http://www.w3.org/1999/xhtml"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui">
<h:head />
<h:body>
<h:form>
<p:dataTable id="registryList" var="RegistryRequest"
value="#{dtRegistryList.registries}" rows="2" paginator="true"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
rowsPerPageTemplate="5,10,15">
<p:column headerText="First Name"
sortBy="#{RegistryRequest.firstName}">
<h:outputText value="#{RegistryRequest.firstName}" />
</p:column>
<p:column headerText="Last Name">
<h:outputText value="#{RegistryRequest.lastName}" />
</p:column>
<p:column headerText="Second Last Name">
<h:outputText value="#{RegistryRequest.secondLastName}" />
</p:column>
</p:dataTable>
</h:form>
</h:body>
</f:view>
我的注册表列表
package com.registryadminportlet.view;
import java.io.Serializable;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.ViewScoped;
import com.registryadminportlet.service.RegistryRequestService;
import com.registryportlet.RegistryModel.model.RegistryRequest;
@ManagedBean(name="dtRegistryList")
@ViewScoped
public class RegistryList implements Serializable {
private List<RegistryRequest> registries;
/**
*
*/
private static final long serialVersionUID = 1L;
@ManagedProperty("#{registryService}")
private RegistryRequestService service;
@PostConstruct
public void init(){
registries = service.getFromDB();
}
public List<RegistryRequest> getRegistries(){
return registries;
}
public void setRegistry(RegistryRequestService service){
this.service = service;
}
}
最后,我的RegistryRequestService
package com.registryadminportlet.service;
import java.util.List;
import javax.faces.bean.ApplicationScoped;
import javax.faces.bean.ManagedBean;
import com.liferay.portal.kernel.exception.SystemException;
import com.registryportlet.RegistryModel.model.RegistryRequest;
import com.registryportlet.RegistryModel.service.RegistryRequestLocalServiceUtil;
@ManagedBean(name = "registryService")
@ApplicationScoped
public class RegistryRequestService {
public List<RegistryRequest> getFromDB(){
int total = 0;
List<RegistryRequest> listado = null;
try {
total = RegistryRequestLocalServiceUtil.getRegistryRequestsCount();
} catch (SystemException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
listado = RegistryRequestLocalServiceUtil.getRegistryRequests(0, total);
} catch (SystemException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return listado;
}
}
如果有人知道为什么我的数据表不能正常工作,我将非常感激。
提前谢谢