我认为我在Primefaces 6.1中的dataTable中发现了livescroll的错误。
我在第二列中有命令链接,它将row / rownumber保存到变量并调用方法来保存文件。它适用于前10个元素(页面大小),但不适用于实时分页附加的任何其他元素 - 而是在第一次设置为0时调用加载。我没有在浏览器控制台或tomcat控制台中看到任何错误。在我的主项目中,页面也会丢失所有css元素,只有文本保留,但它可能是liferay 6.2问题。
如果我通过替换
禁用liveScrollscrollRows="10" liveScroll="true" scrollHeight="90%" scrollable="true"
与
paginatorTemplate="{PreviousPageLink} {NextPageLink}" paginator="true"
一切正常。我已经没有想法如何调试和修复它,任何建议?
xhtml datatable:
<p:dataTable var="live" value="#{LiveLazyModel}" rows="10" lazy="true"
scrollRows="10" liveScroll="true" scrollHeight="90%" scrollable="true"
style="width: 1000px">
<p:column headerText="Id">
<h:outputText value="#{live.id}" id="idlive"/>
</p:column>
<p:column headerText=".txt" style="width: 80px" exportable="false">
<h:commandLink>
<h:outputText value="download"/>
<f:param name="liveId" value="#{live.id}" />
<f:setPropertyActionListener value="#{live}" target="#{LiveLazyModel.selectedRow}"/>
<p:fileDownload value="#{LiveLazyModel.liveStreamedContent}"/>
</h:commandLink>
</p:column>
</p:dataTable>
bean:
@ManagedBean(name = "LiveLazyModel")
@ViewScoped
public class LiveLazyModel extends LazyDataModel {
private Live selectedRow;
@Override
public List load(int first, int pageSize, String sortField, SortOrder sortOrder, Map filters) {
List list = addToList(first, pageSize);
this.setRowCount(100);
this.setPageSize(pageSize);
return list;
}
private List addToList(int first, int pageSize) {
List list = new ArrayList();
for (Integer i = first; i < first + pageSize; i++) {
list.add(new Live(i));
}
return list;
}
public StreamedContent getliveStreamedContent() throws IOException {
String idFrom = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("liveId");
if(selectedRow != null){
InputStream targetStream = IOUtils.toInputStream(selectedRow.id + (Double.toString(Math.random()).substring(1)));
return new DefaultStreamedContent(targetStream, "txt", "idLiveFromSelectedRow" + selectedRow.id + ".txt");
}
if (idFrom != null) {
InputStream targetStream = IOUtils.toInputStream(idFrom + (Double.toString(Math.random()).substring(1)));
return new DefaultStreamedContent(targetStream, "txt", "idLiveFromFacesContext" + idFrom + ".txt");
}
throw new RuntimeException("liveId is null & selectedRow is null ");
}
public void setSelectedRow(Live selectedRow) {
this.selectedRow = selectedRow;
}
}
可以在以下位置找到工作准系统代码: https://github.com/TomaszKocinski/jsfPFLiveScrollBugPagination
运行它:mvn tomcat7:运行应该就够了,localhost:9966 / live