Primefaces dataTable lazy和delete

时间:2015-04-14 13:34:37

标签: jsf primefaces

抱歉我的英文。如何使用带有lazy的dataTable删除行?

Test.xhtml:

<p:dataTable var="testList" value="#{testMB.lazyDataModel}"
             paginator="true"
             lazy="true"
             rows="15"
             paginatorTemplate="{PageLinks}"
             paginatorPosition="bottom">

    <p:column headerText="">
        <h:commandLink action="#{testMB.delete(testList)}">
            Del
        </h:commandLink>
    </p:column>
</p:dataTable>

已更新

类TestMB:

@ManagedBean(name="testMB")
@RequestScoped
public class TestMB extends BaseCrudBean<Long, Test, TestRepository> implements Serializable {

    @ManagedProperty(value = "#{testDAO}")
    public TestRepository repository;
    private LazyDataModel<Test> lazyDataModel;

    @PostConstruct
    public void init() {
        lazyDataModel = new LazyDataModel<Test>() {
            private static final long serialVersionUID = 1L;

            @Override
            public List<Test> load(int first, int pageSize, String sortField,
                    SortOrder sortOrder, Map<String, Object> filters) {
                //..
            }
        };
    }

    public void delete(Test test) {
        getRepository().delete(test);
    }
    //get and set
}

当我不使用lazy="true"lazyDataModel时,删除有效。

0 个答案:

没有答案