edgar 2017-01-02 18:59:00 +00:00
parent 2958730c29
commit 6f136651e8
6 changed files with 29 additions and 13 deletions

View File

@ -18,10 +18,7 @@ public class RelatorioTabelaPreco extends Relatorio {
super(parametros, conexao);
this.isLayoutArtesp = (Boolean) parametros.get("isLayoutArtesp");
if (isLayoutArtesp) {
URL url = getClass().getResource("/com/rjconsultores/ventaboletos/relatorios/imagens/artesp.png");
parametros.put("artesp_logo", url.getPath());
}
this.setCustomDataSource(new ArrayDataSource(this) {
public void initDados() throws Exception {

View File

@ -61,6 +61,7 @@ public class RenderRelatorioJasper {
ResourceBundle resource = ResourceBundle.getBundle("com.rjconsultores.ventaboletos.relatorios.internacionalizacao." + this.relatorio.getNome(), locale);
this.relatorio.getParametros().put(JRParameter.REPORT_RESOURCE_BUNDLE, resource);
this.relatorio.getParametros().put("BASE_DIR",this.relatorio.getBaseDir());
/* Adicionar o arquivo de internacionalização para o subreporte quando informado */
if(this.relatorio.getNomeSubReporte() != null && this.relatorio.getNomeSubReporte().length > 0) {

View File

@ -3,7 +3,7 @@
<property name="ireport.zoom" value="0.9090909090909127"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<parameter name="artesp_logo" class="java.lang.String"/>
<parameter name="BASE_DIR" class="java.lang.String"/>
<field name="origem" class="java.lang.String"/>
<field name="destino" class="java.lang.String"/>
<field name="tarifa" class="java.math.BigDecimal"/>
@ -50,6 +50,11 @@
</textElement>
<textFieldExpression><![CDATA[$F{empresa}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="ac518cbb-e6d1-4edb-b544-11e25b5a4c95" x="440" y="0" width="420" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$P{BASE_DIR}]]></textFieldExpression>
</textField>
</band>
</title>
<pageHeader>
@ -289,8 +294,8 @@
<textFieldExpression><![CDATA[$R{label.msgAviso}]]></textFieldExpression>
</textField>
<image onErrorType="Blank">
<reportElement uuid="c430d4fa-0d54-4292-82b9-b8ea5b1a9aac" x="0" y="15" width="172" height="28"/>
<imageExpression><![CDATA[$P{artesp_logo}]]></imageExpression>
<reportElement uuid="f0aa2830-eda6-4fbd-aa41-e53b17ae2193" x="0" y="15" width="217" height="29"/>
<imageExpression><![CDATA[$P{BASE_DIR}+"/imagens/artesp.png"]]></imageExpression>
</image>
</band>
</pageFooter>

View File

@ -1,5 +1,6 @@
package com.rjconsultores.ventaboletos.relatorios.utilitarios;
import java.net.URL;
import java.sql.Connection;
import java.util.HashSet;
import java.util.Map;
@ -18,6 +19,7 @@ import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource;
public abstract class Relatorio {
private static Logger log = Logger.getLogger(Relatorio.class);
private static final String DEFAULT_BASE_DIR = "/com/rjconsultores/ventaboletos/relatorios";
private Connection conexao;
protected Map<String, Object> parametros;
@ -27,6 +29,7 @@ public abstract class Relatorio {
private Set<String> infoMsg;
private JRBeanCollectionDataSource collectionDataSource;
private String[] nomeSubReporte;
private String baseDir;
protected Relatorio(Map<String, Object> parametros, Connection conexao) {
this.parametros = parametros;
@ -82,6 +85,7 @@ public abstract class Relatorio {
public void setCustomDataSource(IDataSource iDataSource) {
setCustomDataSource(true, iDataSource);
}
/**
* @param iDataSource
* the customDataSource to set
@ -156,4 +160,13 @@ public abstract class Relatorio {
}
}
public String getBaseDir() {
//setado como parametro em RenderRelatorioJasper com a chave "BASE_DIR"
return getClass().getResource(baseDir == null ? DEFAULT_BASE_DIR : baseDir).getPath();
}
public void setBaseDir(String baseDir) {
this.baseDir = baseDir;
}
}