WesleyAlves

Untitled

Oct 31st, 2012
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.23 KB | None | 0 0
  1. DAO:
  2. public List<Matricula> Filtro(Long id){
  3.         Session s = HibernateUtil.getSession();
  4.         Query q = s.createQuery("from Matricula ag where ag.turma.id = :turma");
  5.         q.setParameter("turma", id);
  6.         return q.list();
  7.     }
  8.  
  9.  
  10. BEAN:
  11.  
  12. private List<Turma> filtro = new ArrayList<Turma>();
  13.     public List<Matricula> getFiltro() {
  14.         filtro = new MatriculaDAO().Filtro(idTurma);
  15.         return filtro;
  16.     }
  17.  
  18.     public void setFiltro(List<Matricula> filtro) {
  19.         this.filtro = filtro;
  20.     }
  21.  
  22. XHTML:
  23.  
  24.  
  25.  <p:selectOneMenu id="turma" value="#{matriculaBean.idTurma}" >
  26.                             <f:selectItem itemLabel="Selecione"  />
  27.                             <f:selectItems value="#{matriculaBean.turmas}" var="turma"
  28.                                            itemLabel="#{turma.nome}" itemValue="#{turma.id}" >
  29.  
  30.                             </f:selectItems>
  31.                         <p:ajax event="change" update=":listaAlunos"/>
  32.    
  33.  
  34.                         </p:selectOneMenu>
  35.    <h:form  id="listaAlunos">
  36.                 <p:dataTable value="#{matriculaBean.filtro}"
  37.                              var ="v" emptyMessage="Nenhum aluno matriculado nessa turma.">.............................
Advertisement
Add Comment
Please, Sign In to add comment