[Logo] Neo Framework Forum
  [Search] Busca   [Recent Topics] Tópicos Recentes   [Members]  Lista de Usuários   [Groups] De volta para a página principal 
[Register] Registrar / 
[Login] Entrar 
Suporte a relatórios???  XML
Índice dos Fóruns -> Dúvidas Ir para a página: Anterior  1, 2
Autor Mensagem
vinicius.janones
Template
[Avatar]

Membro desde: 25/06/2007 12:55:10
Mensagens: 105
Localização: Uberlândia - MG
Offline

Bom dia,

Fiz um exemplo de relatorio e me surgiu uma dúvida, fiz um relatorio de bairros, no bean de Bairro tem os atributos:

- Long id
- String nome
- Cidade cidade

Quando fui rodar o relatorio e deu erro dizendo que não havia encontrado o property cidade_id, fui até o bean e criei o paramentro (Long cidade_id) mas coloquei @Transient para não atrapalhar nas telas de crud, resolveu o meu problema, mas queria saber se existe uma forma melhor de fazer isso? Ele não deveria identificar que cidade é o cidade_id, assim como no crud?

A[ ]s

Vinícius O. Janones
[Email]
pedro.goncalves
Equipe
[Avatar]
Membro desde: 17/04/2007 16:12:20
Mensagens: 539
Localização: Belo Horizonte - MG
Offline

Cara!!! nao existe nenhuma restrição quanto a isso..

no iReport quando você colocar um field no tipo dele vc poe tipo assim:

name: cidade
type: org.neoframework.bean.Cidade

entendeu??

ai no seu report usa assim: $F{cidade}.getNome()

Pedro Gonçalves
http://pedrogoncalves.com.br
[Email] [WWW] [MSN]
vinicius.janones
Template
[Avatar]

Membro desde: 25/06/2007 12:55:10
Mensagens: 105
Localização: Uberlândia - MG
Offline

Pedro,

Entendi, vou testar aqui.

Obrigado

A[]s

Vinícius O. Janones
[Email]
vinicius.janones
Template
[Avatar]

Membro desde: 25/06/2007 12:55:10
Mensagens: 105
Localização: Uberlândia - MG
Offline

Paulo,

Este é o meu arquivo jrxml:
Code:
 <jasperReport
 		 name="teste"
 		 columnCount="1"
 		 printOrder="Vertical"
 		 orientation="Portrait"
 		 pageWidth="595"
 		 pageHeight="842"
 		 columnWidth="535"
 		 columnSpacing="0"
 		 leftMargin="30"
 		 rightMargin="30"
 		 topMargin="20"
 		 bottomMargin="20"
 		 whenNoDataType="NoPages"
 		 isTitleNewPage="false"
 		 isSummaryNewPage="false">
 	<property name="ireport.scriptlethandling" value="0" />
 	<property name="ireport.encoding" value="UTF-8" />
 	<import value="java.util.*" />
 	<import value="net.sf.jasperreports.engine.*" />
 	<import value="net.sf.jasperreports.engine.data.*" />
 
 
 	<field name="bairro" class="br.eti.janones.santarem.bean.Bairro"/>
 	<field name="cidade" class="br.eti.janones.santarem.bean.Cidade"/>
 
 		<background>
 			<band height="0"  isSplitAllowed="true" >
 			</band>
 		</background>
 		<title>
 			<band height="50"  isSplitAllowed="true" >
 			</band>
 		</title>
 		<pageHeader>
 			<band height="9"  isSplitAllowed="true" >
 			</band>
 		</pageHeader>
 		<columnHeader>
 			<band height="24"  isSplitAllowed="true" >
 				<staticText>
 					<reportElement
 						x="0"
 						y="6"
 						width="47"
 						height="15"
 						key="staticText-1"/>
 					<box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/>
 					<textElement>
 						<font/>
 					</textElement>
 				<text><![CDATA[Codigo:]]></text>
 				</staticText>
 				<staticText>
 					<reportElement
 						x="48"
 						y="6"
 						width="94"
 						height="15"
 						key="staticText-2"/>
 					<box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/>
 					<textElement>
 						<font/>
 					</textElement>
 				<text><![CDATA[Bairro:]]></text>
 				</staticText>
 				<staticText>
 					<reportElement
 						x="245"
 						y="6"
 						width="94"
 						height="15"
 						key="staticText-3"/>
 					<box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/>
 					<textElement>
 						<font/>
 					</textElement>
 				<text><![CDATA[Cidade:]]></text>
 				</staticText>
 			</band>
 		</columnHeader>
 		<detail>
 			<band height="14"  isSplitAllowed="true" >
 				<textField isStretchWithOverflow="false" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
 					<reportElement
 						x="4"
 						y="0"
 						width="43"
 						height="14"
 						key="textField-1"/>
 					<box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/>
 					<textElement>
 						<font/>
 					</textElement>
 				<textFieldExpression   class="java.lang.Long"><![CDATA[$F{bairro}.getId()]]></textFieldExpression>
 				</textField>
 				<textField isStretchWithOverflow="false" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
 					<reportElement
 						x="47"
 						y="0"
 						width="181"
 						height="14"
 						key="textField-2"/>
 					<box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/>
 					<textElement>
 						<font/>
 					</textElement>
 				<textFieldExpression   class="java.lang.String"><![CDATA[$F{bairro}.getNome()]]></textFieldExpression>
 				</textField>
 				<textField isStretchWithOverflow="false" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
 					<reportElement
 						x="245"
 						y="0"
 						width="181"
 						height="14"
 						key="textField-3"/>
 					<box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/>
 					<textElement>
 						<font/>
 					</textElement>
 				<textFieldExpression   class="java.lang.Long"><![CDATA[$F{cidade}.getId()]]></textFieldExpression>
 				</textField>
 			</band>
 		</detail>
 		<columnFooter>
 			<band height="30"  isSplitAllowed="true" >
 			</band>
 		</columnFooter>
 		<pageFooter>
 			<band height="50"  isSplitAllowed="true" >
 			</band>
 		</pageFooter>
 		<lastPageFooter>
 			<band height="50"  isSplitAllowed="true" >
 			</band>
 		</lastPageFooter>
 		<summary>
 			<band height="50"  isSplitAllowed="true" >
 			</band>
 		</summary>
 </jasperReport>
 
 


Você acha que está errado? O que posso melhorar?

Olha o erro:
Code:
     * net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression : Source text : $F{cidade}
           o Error evaluating expression : Source text : $F{cidade}
           o ClassCastException: br.eti.janones.santarem.bean.Cidade$$EnhancerByCGLIB$$31b41991
 
 

Vinícius O. Janones
[Email]
vinicius.janones
Template
[Avatar]

Membro desde: 25/06/2007 12:55:10
Mensagens: 105
Localização: Uberlândia - MG
Offline

Pedro,

Pode deixar, consegui aqui... resolvi, era um problema na hora de gerar o jasper... fazia tempos que eu não criava um relatorio, hehehe...

Obrigado

Vinícius O. Janones
[Email]
pedro.goncalves
Equipe
[Avatar]
Membro desde: 17/04/2007 16:12:20
Mensagens: 539
Localização: Belo Horizonte - MG
Offline

kkkk.. eu ja ia falar que estava tudo normal kkk

Pedro Gonçalves
http://pedrogoncalves.com.br
[Email] [WWW] [MSN]
 
Índice dos Fóruns -> Dúvidas Ir para a página: Anterior  1, 2
Ir para:   
Powered by JForum 2.1.7 © JForum Team