使用Ajax将数据附加到PrimeFaces的dataTable

时间:2012-05-02 14:54:27

标签: ajax jsf datatable primefaces lazy-loading

我正试图在PrimeFaces的DataTable中使用另一种分页方式。

我想要做的是新页面“垂直”显示,因此新加载的数据必须附加在前一个DataTable的末尾。

类似Facebook的主流,点击“加载旧帖子”会使它们出现在最新的帖子下。

这可能吗?

我几乎尝试了所有使用paginator的东西,但似乎没有办法建立一个“垂直”的dataTable。

如果没有使用PrimeFaces,是否有任何组件可以满足我的需求?

加载应该是惰性的,因此,每次用户决定加载新数据时,都必须执行查询。没有名单或什么!

谢谢:)

编辑:

JSF页面

<pou:dataTable scrollable="true" liveScroll="true" scrollHeight="400" scrollRows="100" value="#{postListBean_1.posts}" var="post">
    <pou:column>
        #{post.testo}
        <hr/>
    </pou:column>                        
</pou:dataTable>

BEAN

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ManagedBeans;

import ejb.PostManagerLocal;
import entity.Post;
import java.io.Serializable;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;

/**
 * La classe si occupa di gestire lo scambio di messaggi tra utenti. Da
 * implementare ancora i metodi per l'invio e per la segnalazione dell'avvenuta
 * lettura.
 *
 * @author stefano
 */
@ManagedBean
@RequestScoped
public class PostListBean_1 implements Serializable {

    @EJB
    private PostManagerLocal postManager;
    private List<Post> posts;
    private int limit = 0;

    /**
     * Get the value of posts
     *
     * @return the value of posts
     */
    public List<Post> getPosts() {
        limit+=4;
        makePosts();
        return posts;
    }

    /**
     * Set the value of posts
     *
     * @param posts new value of posts
     */
    public void setPosts(List<Post> posts) {
        this.posts = posts;
    }

    /**
     * Creates a new instance of PostListBean
     */
    public PostListBean_1() {
    }

    /**
     * Inizializza la lista dei posts, prendendoli in ordine inverso, in modo da
     * avere prima i più recenti
     */
    @PostConstruct
    public void makePosts() {
        int[] range = {0, limit};
        posts = postManager.findRangeReverse(range);
    }
}

0 个答案:

没有答案
相关问题