2011-02-06 57 views
0

我似乎無法從moviesDetail.jsp獲得每部電影的評論。我究竟做錯了什麼?如何從當前上下文更新模型信息

  <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> 

控制器類;

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 = jpaController.findByMovie(movie.getIdMovies()); 
    } 
    return commentsItemsPerMovie; 
} 

門面

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(); 
} 

回答

0

用在電影豆意見收集和儲存commnets ID在影片中設置連接

相關問題