package br.empresateste.testerelatorio.bean;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import javax.faces.context.FacesContext;
import javax.servlet.http.HttpSession;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRResultSetDataSource;
import net.sf.jasperreports.engine.JasperExportManager;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource;
import br.empresateste.testerelatorio.conexao.Conexao;
import br.empresateste.testerelatorio.dao.AlunoDao;
import br.empresateste.testerelatorio.model.Aluno;
public class RelatorioBean {
private String saida;
public String geraRelatorioPassandoConexao() {
saida = null;
String jasper = getDiretorioReal("/jasper/professores_por_aluno.jasper");
Connection conexao = null;
try {
conexao = new Conexao().getConexao();
JasperPrint print = JasperFillManager.fillReport(jasper, null, conexao);
preenchePdf(print);
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (conexao != null)
conexao.close();
} catch (SQLException e) {
}
}
return "exibeRelatorio";
}
public String geraRelatorioPassandoResultSet() {
saida = null;
String jasper = getDiretorioReal("/jasper/professores_por_aluno.jasper");
Connection conexao = null;
try {
conexao = new Conexao().getConexao();
JRResultSetDataSource jrsds = new JRResultSetDataSource(getResultSet(conexao));
JasperPrint print = JasperFillManager.fillReport(jasper, null, jrsds);
preenchePdf(print);
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (conexao != null)
conexao.close();
} catch (SQLException e) {
}
}
return "exibeRelatorio";
}
public String geraRelatorioPassandoListaDeObjetos() {
saida = null;
String jasper = getDiretorioReal("/jasper/professores_por_aluno_com_lista.jasper");
Connection conexao = null;
try {
conexao = new Conexao().getConexao();
Map<String, Object> map = new HashMap<String, Object>();
map.put("REPORT_CONNECTION", conexao);
map.put("SUBREPORT_DIR", getDiretorioReal("/jasper/") + "/");
ArrayList<Aluno> alunos = getListaAlunos(conexao);
JRBeanCollectionDataSource ds = new JRBeanCollectionDataSource(alunos);
JasperPrint print = JasperFillManager.fillReport(jasper, map, ds);
preenchePdf(print);
} catch (Exception e) {
e.printStackTrace();
}
return "exibeRelatorio";
}
private ResultSet getResultSet(Connection conexao) throws SQLException, ClassNotFoundException {
Statement stmt = conexao.createStatement();
ResultSet rs = stmt.executeQuery("SELECT aluno.nome AS aluno_nome, " +
"aluno.matricula AS aluno_matricula, professor.nome AS professor_nome, " +
"aluno.id_aluno AS aluno_id_aluno FROM aluno aluno " +
"INNER JOIN professores_alunos professores_alunos ON aluno.id_aluno = professores_alunos.id_aluno " +
"INNER JOIN `professor` professor ON professores_alunos.id_professor = professor.id_professor");
return rs;
}
private ArrayList<Aluno> getListaAlunos(Connection conexao) throws SQLException {
return (ArrayList<Aluno>) new AlunoDao().loadAll(conexao);
}
private void preenchePdf(JasperPrint print) throws JRException {
saida = getDiretorioReal("/pdf/relatorio.pdf");
JasperExportManager.exportReportToPdfFile(print, saida);
saida = getContextPath() + "/pdf/relatorio.pdf";
}
private String getDiretorioReal(String diretorio) {
HttpSession session = (HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(false);
return session.getServletContext().getRealPath(diretorio);
}
private String getContextPath() {
HttpSession session = (HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(false);
return session.getServletContext().getContextPath();
}
public String getSaida() {
return saida;
}
public void setSaida(String saida) {
this.saida = saida;
}
}
package br.empresateste.testerelatorio.conexao;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class Conexao {
private Connection conexao;
public Conexao() throws ClassNotFoundException, SQLException {
criaConexao();
}
public void criaConexao() throws ClassNotFoundException, SQLException {
String endereco = "localhost";
String porta = "3306";
String banco = "academico";
String usuario = "root";
String senha = "debian23";
try {
Class.forName("com.mysql.jdbc.Driver");
conexao = DriverManager.getConnection("jdbc:mysql://" + endereco
+ ":" + porta + "/" + banco + "?user=" + usuario
+ "&password=" + senha);
} catch (ClassNotFoundException ex) {
throw ex;
} catch (SQLException ex) {
throw ex;
}
}
public void fechaConexao() throws SQLException {
conexao.close();
conexao = null;
}
public boolean isFechada() {
try {
return conexao.isClosed();
} catch (SQLException ex) {
return false;
}
}
public Connection getConexao() {
return conexao;
}
}
package br.empresateste.testerelatorio.dao;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import br.empresateste.testerelatorio.exception.NotFoundException;
import br.empresateste.testerelatorio.model.Aluno;
public class AlunoDao {
public Aluno createValueObject() {
return new Aluno();
}
public Aluno getObject(Connection conn, int idAluno) throws NotFoundException, SQLException {
Aluno valueObject = createValueObject();
valueObject.setIdAluno(idAluno);
load(conn, valueObject);
return valueObject;
}
public void load(Connection conn, Aluno valueObject) throws NotFoundException, SQLException {
String sql = "SELECT * FROM aluno WHERE (id_aluno = ? ) ";
PreparedStatement stmt = null;
try {
stmt = conn.prepareStatement(sql);
stmt.setInt(1, valueObject.getIdAluno());
singleQuery(conn, stmt, valueObject);
} finally {
if (stmt != null)
stmt.close();
}
}
public List<Aluno> loadAll(Connection conn) throws SQLException {
String sql = "SELECT * FROM aluno ORDER BY id_aluno ASC ";
List<Aluno> searchResults = listQuery(conn, conn.prepareStatement(sql));
return searchResults;
}
public synchronized void create(Connection conn, Aluno valueObject) throws SQLException {
String sql = "";
PreparedStatement stmt = null;
ResultSet result = null;
try {
sql = "INSERT INTO aluno ( nome, matricula, situacao_frequencia, "
+ "situacao_pagamento) VALUES (?, ?, ?, ?) ";
stmt = conn.prepareStatement(sql);
stmt.setString(1, valueObject.getNome());
stmt.setString(2, valueObject.getMatricula());
stmt.setString(3, valueObject.getSituacaoFrequencia());
stmt.setString(4, valueObject.getSituacaoPagamento());
int rowcount = databaseUpdate(conn, stmt);
if (rowcount != 1) {
//System.out.println("PrimaryKey Error when updating DB!");
throw new SQLException("PrimaryKey Error when updating DB!");
}
} finally {
if (stmt != null)
stmt.close();
}
sql = "SELECT last_insert_id()";
try {
stmt = conn.prepareStatement(sql);
result = stmt.executeQuery();
if (result.next()) {
valueObject.setIdAluno((int)result.getLong(1));
} else {
//System.out.println("Unable to find primary-key for created object!");
throw new SQLException("Unable to find primary-key for created object!");
}
} finally {
if (result != null)
result.close();
if (stmt != null)
stmt.close();
}
}
public void save(Connection conn, Aluno valueObject)
throws NotFoundException, SQLException {
String sql = "UPDATE aluno SET nome = ?, matricula = ?, situacao_frequencia = ?, "
+ "situacao_pagamento = ? WHERE (id_aluno = ? ) ";
PreparedStatement stmt = null;
try {
stmt = conn.prepareStatement(sql);
stmt.setString(1, valueObject.getNome());
stmt.setString(2, valueObject.getMatricula());
stmt.setString(3, valueObject.getSituacaoFrequencia());
stmt.setString(4, valueObject.getSituacaoPagamento());
stmt.setInt(5, valueObject.getIdAluno());
int rowcount = databaseUpdate(conn, stmt);
if (rowcount == 0) {
//System.out.println("Object could not be saved! (PrimaryKey not found)");
throw new NotFoundException("Object could not be saved! (PrimaryKey not found)");
}
if (rowcount > 1) {
//System.out.println("PrimaryKey Error when updating DB! (Many objects were affected!)");
throw new SQLException("PrimaryKey Error when updating DB! (Many objects were affected!)");
}
} finally {
if (stmt != null)
stmt.close();
}
}
public void delete(Connection conn, Aluno valueObject)
throws NotFoundException, SQLException {
String sql = "DELETE FROM aluno WHERE (id_aluno = ? ) ";
PreparedStatement stmt = null;
try {
stmt = conn.prepareStatement(sql);
stmt.setInt(1, valueObject.getIdAluno());
int rowcount = databaseUpdate(conn, stmt);
if (rowcount == 0) {
//System.out.println("Object could not be deleted (PrimaryKey not found)");
throw new NotFoundException("Object could not be deleted! (PrimaryKey not found)");
}
if (rowcount > 1) {
//System.out.println("PrimaryKey Error when updating DB! (Many objects were deleted!)");
throw new SQLException("PrimaryKey Error when updating DB! (Many objects were deleted!)");
}
} finally {
if (stmt != null)
stmt.close();
}
}
public void deleteAll(Connection conn) throws SQLException {
String sql = "DELETE FROM aluno";
PreparedStatement stmt = null;
try {
stmt = conn.prepareStatement(sql);
databaseUpdate(conn, stmt);
} finally {
if (stmt != null)
stmt.close();
}
}
public int countAll(Connection conn) throws SQLException {
String sql = "SELECT count(*) FROM aluno";
PreparedStatement stmt = null;
ResultSet result = null;
int allRows = 0;
try {
stmt = conn.prepareStatement(sql);
result = stmt.executeQuery();
if (result.next())
allRows = result.getInt(1);
} finally {
if (result != null)
result.close();
if (stmt != null)
stmt.close();
}
return allRows;
}
public List<Aluno> searchMatching(Connection conn, Aluno valueObject) throws SQLException {
List<Aluno> searchResults;
boolean first = true;
StringBuffer sql = new StringBuffer("SELECT * FROM aluno WHERE 1=1 ");
if (valueObject.getIdAluno() != 0) {
if (first) { first = false; }
sql.append("AND id_aluno = ").append(valueObject.getIdAluno()).append(" ");
}
if (valueObject.getNome() != null) {
if (first) { first = false; }
sql.append("AND nome LIKE '").append(valueObject.getNome()).append("%' ");
}
if (valueObject.getMatricula() != null) {
if (first) { first = false; }
sql.append("AND matricula LIKE '").append(valueObject.getMatricula()).append("%' ");
}
if (valueObject.getSituacaoFrequencia() != null) {
if (first) { first = false; }
sql.append("AND situacao_frequencia LIKE '").append(valueObject.getSituacaoFrequencia()).append("%' ");
}
if (valueObject.getSituacaoPagamento() != null) {
if (first) { first = false; }
sql.append("AND situacao_pagamento LIKE '").append(valueObject.getSituacaoPagamento()).append("%' ");
}
sql.append("ORDER BY id_aluno ASC ");
// Prevent accidential full table results.
// Use loadAll if all rows must be returned.
if (first)
searchResults = new ArrayList<Aluno>();
else
searchResults = listQuery(conn, conn.prepareStatement(sql.toString()));
return searchResults;
}
public String getDaogenVersion() {
return "DaoGen version 2.4.1";
}
protected int databaseUpdate(Connection conn, PreparedStatement stmt) throws SQLException {
int result = stmt.executeUpdate();
return result;
}
protected void singleQuery(Connection conn, PreparedStatement stmt, Aluno valueObject)
throws NotFoundException, SQLException {
ResultSet result = null;
try {
result = stmt.executeQuery();
if (result.next()) {
valueObject.setIdAluno(result.getInt("id_aluno"));
valueObject.setNome(result.getString("nome"));
valueObject.setMatricula(result.getString("matricula"));
valueObject.setSituacaoFrequencia(result.getString("situacao_frequencia"));
valueObject.setSituacaoPagamento(result.getString("situacao_pagamento"));
} else {
//System.out.println("Aluno Object Not Found!");
throw new NotFoundException("Aluno Object Not Found!");
}
} finally {
if (result != null)
result.close();
if (stmt != null)
stmt.close();
}
}
protected List<Aluno> listQuery(Connection conn, PreparedStatement stmt) throws SQLException {
ArrayList<Aluno> searchResults = new ArrayList<Aluno>();
ResultSet result = null;
try {
result = stmt.executeQuery();
while (result.next()) {
Aluno temp = createValueObject();
temp.setIdAluno(result.getInt("id_aluno"));
temp.setNome(result.getString("nome"));
temp.setMatricula(result.getString("matricula"));
temp.setSituacaoFrequencia(result.getString("situacao_frequencia"));
temp.setSituacaoPagamento(result.getString("situacao_pagamento"));
searchResults.add(temp);
}
} finally {
if (result != null)
result.close();
if (stmt != null)
stmt.close();
}
return (List<Aluno>)searchResults;
}
}
package br.empresateste.testerelatorio.exception;
public class NotFoundException extends Exception {
private static final long serialVersionUID = -6722261954538121254L;
public NotFoundException(String msg) {
super(msg);
}
}
package br.empresateste.testerelatorio.model;
import java.io.*;
public class Aluno implements Cloneable, Serializable {
private static final long serialVersionUID = 1L;
private int idAluno;
private String nome;
private String matricula;
private String situacaoFrequencia;
private String situacaoPagamento;
public Aluno () {
}
public Aluno (int idAlunoIn) {
this.idAluno = idAlunoIn;
}
public int getIdAluno() {
return this.idAluno;
}
public void setIdAluno(int idAlunoIn) {
this.idAluno = idAlunoIn;
}
public String getNome() {
return this.nome;
}
public void setNome(String nomeIn) {
this.nome = nomeIn;
}
public String getMatricula() {
return this.matricula;
}
public void setMatricula(String matriculaIn) {
this.matricula = matriculaIn;
}
public String getSituacaoFrequencia() {
return this.situacaoFrequencia;
}
public void setSituacaoFrequencia(String situacaoFrequenciaIn) {
this.situacaoFrequencia = situacaoFrequenciaIn;
}
public String getSituacaoPagamento() {
return this.situacaoPagamento;
}
public void setSituacaoPagamento(String situacaoPagamentoIn) {
this.situacaoPagamento = situacaoPagamentoIn;
}
public void setAll(int idAlunoIn,
String nomeIn,
String matriculaIn,
String situacaoFrequenciaIn,
String situacaoPagamentoIn) {
this.idAluno = idAlunoIn;
this.nome = nomeIn;
this.matricula = matriculaIn;
this.situacaoFrequencia = situacaoFrequenciaIn;
this.situacaoPagamento = situacaoPagamentoIn;
}
public boolean hasEqualMapping(Aluno valueObject) {
if (valueObject.getIdAluno() != this.idAluno) {
return(false);
}
if (this.nome == null) {
if (valueObject.getNome() != null)
return(false);
} else if (!this.nome.equals(valueObject.getNome())) {
return(false);
}
if (this.matricula == null) {
if (valueObject.getMatricula() != null)
return(false);
} else if (!this.matricula.equals(valueObject.getMatricula())) {
return(false);
}
if (this.situacaoFrequencia == null) {
if (valueObject.getSituacaoFrequencia() != null)
return(false);
} else if (!this.situacaoFrequencia.equals(valueObject.getSituacaoFrequencia())) {
return(false);
}
if (this.situacaoPagamento == null) {
if (valueObject.getSituacaoPagamento() != null)
return(false);
} else if (!this.situacaoPagamento.equals(valueObject.getSituacaoPagamento())) {
return(false);
}
return true;
}
public String toString() {
StringBuffer out = new StringBuffer(this.getDaogenVersion());
out.append("\nclass Aluno, mapping to table aluno\n");
out.append("Persistent attributes: \n");
out.append("idAluno = " + this.idAluno + "\n");
out.append("nome = " + this.nome + "\n");
out.append("matricula = " + this.matricula + "\n");
out.append("situacaoFrequencia = " + this.situacaoFrequencia + "\n");
out.append("situacaoPagamento = " + this.situacaoPagamento + "\n");
return out.toString();
}
public Object clone() {
Aluno cloned = new Aluno();
cloned.setIdAluno(this.idAluno);
if (this.nome != null)
cloned.setNome(new String(this.nome));
if (this.matricula != null)
cloned.setMatricula(new String(this.matricula));
if (this.situacaoFrequencia != null)
cloned.setSituacaoFrequencia(new String(this.situacaoFrequencia));
if (this.situacaoPagamento != null)
cloned.setSituacaoPagamento(new String(this.situacaoPagamento));
return cloned;
}
public String getDaogenVersion() {
return "DaoGen version 2.4.1";
}
}
<?xml version="1.0" encoding="iso-8859-1" ?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.0"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core">
<f:view >
<body>
<h:form id="form">
<br />
<br />
<center>
<h:commandLink target="_blank" action="#{relatorioBean.geraRelatorioPassandoConexao}" value="Gerar relatório passando a conexão." /><br />
<h:commandLink target="_blank" action="#{relatorioBean.geraRelatorioPassandoResultSet}" value="Gerar relatório passando o ResultSet." /><br />
<h:commandLink target="_blank" action="#{relatorioBean.geraRelatorioPassandoListaDeObjetos}" value="Gerar relatório passando uma lista de objetos." /><br />
</center>
</h:form>
</body>
</f:view>
</jsp:root>
<?xml version="1.0" encoding="iso-8859-1" ?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.0"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core">
<f:view>
<h:outputText rendered="#{empty relatorioBean.saida}" value="Relatório não gerado. Consulte o Administrador do Sistema." />
<f:subview id="relatorio" rendered="#{not empty relatorioBean.saida}">
<iframe id="iframe" src="#{relatorioBean.saida}" width="99%"
height="600px" style="min-height: 400px;">
</iframe>
</f:subview>
</f:view>
</jsp:root>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c"%>
<c:redirect url="index.jsf"/>
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID" version="2.5">
<display-name>testeRelatorio</display-name>
<welcome-file-list>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<!-- Java Server Faces -->
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<context-param>
<param-name>javax.faces.CONFIG_FILES</param-name>
<param-value>/WEB-INF/faces-config.xml</param-value>
</context-param>
<!-- Jsf - Manter Componentes para o Browser -->
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>client</param-value>
</context-param>
<!-- Facelets -->
<context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.jspx</param-value>
</context-param>
<context-param>
<param-name>facelets.DEVELOPMENT</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>facelets.REFRESH_PERIOD</param-name>
<param-value>1</param-value>
</context-param>
</web-app>
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL';
CREATE SCHEMA IF NOT EXISTS `academico` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci ;
USE `academico`;
-- -----------------------------------------------------
-- Table `academico`.`aluno`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `academico`.`aluno` (
`id_aluno` INT NOT NULL AUTO_INCREMENT ,
`nome` VARCHAR(120) NOT NULL ,
`matricula` VARCHAR(20) NOT NULL COMMENT 'unique key' ,
`situacao_frequencia` CHAR(1) NOT NULL COMMENT 'A - ATIVO\nI - INATIVO ' ,
`situacao_pagamento` CHAR(1) NOT NULL COMMENT 'A - ADIMPLENTE\nI - INADIMPLENTE' ,
PRIMARY KEY (`id_aluno`) ,
UNIQUE INDEX `UNIQUE` (`matricula` ASC) )
ENGINE = InnoDB
COMMENT = 'Tabela de alunos da escola';
-- -----------------------------------------------------
-- Table `academico`.`professor`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `academico`.`professor` (
`id_professor` INT NOT NULL AUTO_INCREMENT ,
`nome` VARCHAR(120) NOT NULL ,
`matricula` VARCHAR(20) NOT NULL ,
`titulacao` VARCHAR(20) NOT NULL ,
`situacao` CHAR(1) NOT NULL COMMENT 'A - ATIVO\nP - APOSENTADO\nL - LICENCIADO\nC - CEDIDO' ,
PRIMARY KEY (`id_professor`) ,
UNIQUE INDEX `UNIQUE` (`matricula` ASC) )
ENGINE = InnoDB
COMMENT = 'Tabela de professores dos alunos';
-- -----------------------------------------------------
-- Table `academico`.`professores_alunos`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `academico`.`professores_alunos` (
`id_professor` INT NOT NULL ,
`id_aluno` INT NOT NULL ,
PRIMARY KEY (`id_aluno`, `id_professor`) ,
INDEX `fk_aluno` (`id_aluno` ASC) ,
INDEX `fk_professor` (`id_professor` ASC) ,
CONSTRAINT `fk_aluno`
FOREIGN KEY (`id_aluno` )
REFERENCES `academico`.`aluno` (`id_aluno` )
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_professor`
FOREIGN KEY (`id_professor` )
REFERENCES `academico`.`professor` (`id_professor` )
ON DELETE NO ACTION
ON UPDATE NO ACTION);
SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
<?xml version="1.0" encoding="UTF-8"?>
<faces-config
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd"
version="1.2">
<application>
<view-handler>com.sun.facelets.FaceletViewHandler</view-handler>
</application>
<managed-bean>
<description>Bean para gerar relatórios.</description>
<managed-bean-name>relatorioBean</managed-bean-name>
<managed-bean-class>br.empresateste.testerelatorio.bean.RelatorioBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
<navigation-rule>
<from-view-id>*</from-view-id>
<navigation-case>
<from-outcome>index</from-outcome>
<to-view-id>/index.jspx</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>exibeRelatorio</from-outcome>
<to-view-id>/relatorio.jspx</to-view-id>
</navigation-case>
</navigation-rule>
</faces-config>