Jump to content
We've recently updated our Privacy Statement, available here ×

How to pass type F or type P parameters to subreports?


fillipedesenvolvedor
Go to solution Solved by C-Box,

Recommended Posts

Gentlemen,


 


I created a parent report and in it I created two subreports, I have some text fields and some parameters that I need to pass to the subreports, I already created the text fields in the main report and in the subs, I already passed in the properties all the parameters, but still not showing the data, i'm using data source for system application, that's where i do an instance of the class, what could be happening? the version i am using is jasper 5.6.0!

Link to comment
Share on other sites

  • Replies 7
  • Created
  • Last Reply

Top Posters In This Topic

Hello,

Can you provide us a bit more insight.

Are you doing this in Jaspersoft server or with the API?

 

What data class of parameter are you passing? 

Let's assume you are not using an array (collection) containing multiple values.

If you pass a $P{Parameter} you will pass the initial selected.

If you pass a $F{Field} you will pass the selected column field for that element.  (For a table, it will be the field from the row where the hyperlink is selected)

 

When you say sub-report, do you mean that you hyperlinked an element field to another report?

If it is the case of the hyperlink,

does the link work work but not pass the parameters?

Do you see the parameters in the URL?

 

If the link does not work, make sure to set the link Type to ReportExecution.

If you do not see the parameters, make sure you pass them in the Hyperlink parameters.

Be sure to pass the Field by selecting the fild in the expression editor.

$F{FieldName}

Add a parameters add to indicate the sub report URL:

Name:  _report

Expression "/reports/Parent_Folder/ReportName"

url2.png

Link to comment
Share on other sites

É que estou usando o google chrome para fazer a conversão para o inglês e talvez não saia a tradução corretamente kkk, mas enfim... Vou esclarecer melhor com mais detalhes.

Tenho uma classe que gera os relatórios, nela aplico este modelo de código : 

JasperPrint print = JasperFillManager.fillReport(report, params, new JRBeanCollectionDataSource(listaRelAcompPreNatal));

a onde que os params = os paramêtros que já estou passando

a listaRelAcompPreNatal possui uma coleção que é uma lista a onde contém todos os atributos, estes atributos está exatamente o mesmo nome lá dos meus Fields que é do tipo F

no relatório principal Tenho todos estes Fields e nos subs relatórios que está inserido no principal também tem todos os fields !, mas quando executo na aplicação, a aba detail está vindo branca porque não está carregando nenhum dado, então logo isso quer dizer que os meus Fields que é da minha coleção de dados(listaRelAcompPreNatal) nos subs relatórios estão todos vazios, é como se somente o relatório principal estivesse acesso a essa minha coleção de dados que se chama listaRelAcompPreNatal, agora quero fazer com que os meus subs relatórios tenha acesso a está minha coleção de dados que possui os valores de todos os Fields entendeu ?

Link to comment
Share on other sites

Eu tenho um relatório Principal, a onde inseri três sub relatórios, a forma como inseri eles foi como um endereçamento estático, passando a path msm a onde se encontra o arquivo. Tenho vários Fields, quero usar a mesma coleção de dados que uso no principal para os outros dois sub-relatórios.

Vou inserir o link : https://prnt.sc/pjoetr

Este é o modelo que fiz !

Link to comment
Share on other sites

No sub-relatórios nas propriedades > Parameters eu inseri todos os campos Fields que eu preciso que ele receba os valores da minha coleção de dados que é a lista listaRelAcompPreNatal e na opção Connection Type eu escolhi > Use a datasource expression e na opção data source expression eu preciso passar a minha coleção listaRelAcompPreNatal novamente ? pois quando vou compilar o arquivo, ele pede para que seja criado o paramêtro listaRelAcompPreNatal, está entendendo ?

Link to comment
Share on other sites

I'm transmitting the data using JRBeanCollectionDataSource and there was a need to use this same for subreports, in the subreports already contains all the fields that I need to list. In the list that is being passed inside JRBeanCollectionDataSource is all the data in it, I need to get this list and pass it in the subreports so that the data is shown, but everything is coming to null, because I believe the subreport is not receiving the JRBeanCollectionDataSource.

How can I do it?

Link to comment
Share on other sites

  • Solution

You should use a copy of your passed JRBeanCollectionDataSource if you use it multiple times in SubReports. Otherwise the internal pointer to the next record will be forwarded so that the data are just shown once. So you can use the clone() method for that purpose in your SubReport DataSourceExpression, when I remember right. ;-)

hth + regards

C-Box

Link to comment
Share on other sites

  • 1 year later...

Using Jaspersoft Studio without Jasper server - I want to pass a value to a sub-report via a hyperlink. I.E. Click here to see details. How do you pass a value to a subreport without using a local path for an expression. In other words, for the parameter expression with name = _report, can I just point to a sub-report? The sub-report is in the same project and prompts for input. Data type is a string (postgresql). This seems so elementary. 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...