Jsf 将元素添加到数据列表
比方说,我有这样的Jsf 将元素添加到数据列表,jsf,primefaces,Jsf,Primefaces,比方说,我有这样的.xhtml <h:form id="form"> <p:dataList id="carList" value="#{myBean.cars}" var="car"> #{car.brand}, #{car.year} </p:dataList> <p:commandButton value="Add new car" actionListener="#{myBean.addCar}" upd
.xhtml
<h:form id="form">
<p:dataList id="carList" value="#{myBean.cars}" var="car">
#{car.brand}, #{car.year}
</p:dataList>
<p:commandButton value="Add new car" actionListener="#{myBean.addCar}" update="@form"/>
</h:form>
#{car.brand},{car.year}
按下addnewcar
按钮后,一个新的car对象被添加到myBean.cars
,数据列表被完全重新呈现。带有更改的Ajax响应不仅包含新车,还包含所有现有汽车和新车
因为我有更复杂的模型和大量的数据,所以重新渲染所有元素非常耗时。是否可以添加新元素而无需重新对列表中所有现有元素进行排序?否,不能直接以这种方式添加。但我正在考虑开始为这些PrimeFaces组件中的一些组件实现一个功能,但这不会在2个月内准备好。如果可以使用其他组件,那么datatable支持延迟加载和获取(仅显示大记录集中的一些记录)