Permalink
Browse files

Módulo 7, criação do managed bean e adição da listagem de alunos na

página.
  • Loading branch information...
1 parent 9a87a92 commit 9dd18346b9833f183f0011607f44c36c4e3b56bf @wegneto committed Oct 13, 2011
@@ -47,7 +47,7 @@ public boolean estaMatriculado(Aluno aluno) {
return obterAlunosMatriculados().contains(aluno);
}
- private List<Aluno> obterAlunosMatriculados() {
+ public List<Aluno> obterAlunosMatriculados() {
return alunoBC.findAll();
}
@@ -0,0 +1,21 @@
+package br.gov.serpro.inscricao.view;
+
+import java.util.List;
+
+import javax.inject.Inject;
+
+import br.gov.frameworkdemoiselle.stereotype.ViewController;
+import br.gov.serpro.inscricao.business.TurmaBC;
+import br.gov.serpro.inscricao.entity.Aluno;
+
+@ViewController
+public class TurmaMB {
+
+ @Inject
+ private TurmaBC bc;
+
+ public List<Aluno> getAlunosMatriculados() {
+ return bc.obterAlunosMatriculados();
+ }
+
+}
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
+
+ <persistence-unit name="inscricao-ds" transaction-type="RESOURCE_LOCAL">
+ <non-jta-data-source>java:/DefaultDS</non-jta-data-source>
+
+ <class>br.gov.serpro.inscricao.entity.Aluno</class>
+
+ <properties>
+ <property name="hibernate.show_sql" value="true" />
+ <property name="hibernate.format_sql" value="false" />
+ <property name="hibernate.hbm2ddl.auto" value="create-drop" />
+ </properties>
+ </persistence-unit>
+
+</persistence>
@@ -1,21 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
-
- <persistence-unit name="inscricao-ds" transaction-type="RESOURCE_LOCAL">
-
- <class>br.gov.serpro.inscricao.entity.Aluno</class>
-
- <properties>
- <property name="javax.persistence.jdbc.driver" value="org.hsqldb.jdbcDriver" />
- <property name="javax.persistence.jdbc.user" value="sa" />
- <property name="javax.persistence.jdbc.password" value="" />
- <property name="javax.persistence.jdbc.url" value="jdbc:hsqldb:mem:." />
-
- <property name="eclipselink.logging.level" value="FINE" />
- <property name="eclipselink.ddl-generation" value="create-tables" />
- <property name="eclipselink.ddl-generation.output-mode" value="database" />
- </properties>
- </persistence-unit>
-
-</persistence>
@@ -1,6 +1,18 @@
<html xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html">
- Olá mundo!
+ <h:body>
+
+ Olá mundo!
+
+ <h:dataTable id="lista" var="aluno" value="#{turmaMB.alunosMatriculados}">
+ <h:column>
+ <h:outputText value="#{aluno.matricula}" />
+ </h:column>
+ <h:column>
+ <h:outputText value="#{aluno.nome}" />
+ </h:column>
+ </h:dataTable>
+ </h:body>
</html>

0 comments on commit 9dd1834

Please sign in to comment.