开发者

how to update model information from current context

开发者 https://www.devze.com 2023-02-09 01:57 出处:网络
I can not seem to get comments per movie from moviesDetail.jsp. What am I doing wrong? <h:dataTable value=\"#{comments.commentsItemsPerMovie}\" var=\"item\" border=\"0\" cellpadding=\"2\" cellspac

I can not seem to get comments per movie from moviesDetail.jsp. What am I doing wrong?

           <h:dataTable value="#{comments.commentsItemsPerMovie}" var="item" border="0" cellpadding="2" cellspacing="0" rowClasses="jsfcrud_odd_row,jsfcrud_even_row" rules="all" style="border:solid 1px">
                <h:column>
                    <f:facet name="header">
                        <h:outputText value="IdUser"/>
                    </f:facet>
                    <h:outputText value="#{item.idUser.user}"/>
                </h:column>
                <h:column>
                    <f:facet name="header">
                        <h:outputText value="Text"/>
                    </f:facet>
                    <h:outputText value="#{item.text}"/>
                </h:column>
            </h:dataTable>

Controller Class;

private List<Comments> commentsItemsPerMovie = null;
private Movies movie;
private Comments comment;


public List<Comments> getCommentsItemsPerMovie() {
    if (commentsItemsPerMovie == null) {
        getPagingInfo();
        movies = 
        (Movies) FacesContext
        .getCurrentInstance().getELContext().getContext(Movies.class);
        commentsItemsPerMovie = jpaContr开发者_开发百科oller.findByMovie(movie.getIdMovies());
    }
    return commentsItemsPerMovie;
}

Facade

public List<Comentarios> findByMovie(int movie) {
    CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
    cq.select(cq.from(Comments.class));
    Query q = em.createQuery("SELECT c FROM Comments WHERE c.idMovies = :"+movie+"");
    return q.getResultList();
}


Used a collection of comments in the movie bean and stored such commnets id in the movie to set connection

0

精彩评论

暂无评论...
验证码 换一张
取 消