Dynamically change the background color of an object - jasper-reports

I am using iReports for generating the PDF form. The requirement is to dynamically set jrxml object backgroundcolor.
I tried to pass the color from java to jrxml. IT didn't work. Any other ideas?

You can try to use styles of iReport and apply some predefied style
according to value of dynamically passed parameter.
Before generating the report you can parse jrxml using some lighter
language (Groovy, Ruby), find needed tag and correct value of appropriate
property.

Related

Jasper Reports - How to get JRXML components with mixed styles or dynamic widths on text boxes?

When buliding jasper reports JRXML files I want to be able to have a row of dynamically width'd text boxes of mixing styles. It does not seem like Jasper supports that so I'm stuck with this:
Notice how I used two static text boxes for this display with fixed widths. This is because I cannot mix the bold + normal font styles inside a component.
I would rather something like this:
Where the NOW() and $P{name} will automatically stretch out and look real nice.
Note: I cannot use the HTML component due to this issue http://community.jaspersoft.com/questions/540569/html-component-font and https://community.jaspersoft.com/jasperreports-library/issues/4411-0
Is there a way to code JRXML files with dynamically width'd Textboxes?
Actually, you can mix styles using markup in a single text box. Jasper supports (simple) HTML, RTF and a custom jasper-styling.
Check the "markup" property.
But I am not aware that you could insert artificial borders around the values when using a single textbox.

iReport: localized default values for parameters

How to use localized default values for parameters in iReport?
Using a $R{message.key} as the parameter default value has negative consequences in the "Read fields" functionality of iReport's SQL editor. More precisely, the following error is shown (after pressing the Read fields button in Report query dialog):
Sourced file: inline evaluation of: ``$R{message.key}'' : Attempt to access property on undefined variable or class name
Any way around this iReport problem?
Here is the image to illustrate the problem:
I think this is a iReport's bug.
You can temporary comment the defaultValueExpression expression and add the fields via the Report query -> Read fields button.
Or you can manually add the fields declaration.
This is iReport bug ! To solve this issue please follow the below steps.
Open XML File
Remove defaultValueExpression tag value.

What is the purpose of ireport.x and ireport.y property in iReport?

Can anyone let me know the purpose of property ireport.x and ireport.y in JasperReports .jrxml files?
Thanks in advance.
The parameters ireport.x, ireport.y and ireport.zoom are determine how to show report's template in iReport. Its just a settings for default displaying report in this designer (iReport).
The parameters ireport.x and ireport.y are determine the default position for template (after opening in designer).
The parameter ireport.zoom is determine the default zoom for template (after opening in designer).

How to modify a <staticText> element in a JasperReport

I've an xml that I restore from my Data base containing jasperreports. Here's an excerpt:
<staticText>......<text><![CDATA[Entidad Bancaria:]]></text></staticText>
I want to programatically substitute the content of the CDATA element and then regenerate the JasperReport, but I found that the API doesn't allow to do this (or it's too difficult to figure out how). So I tried to convert the jasper xml into a string, from string to Inputstream (to match the signature of JasperFillManager.fillReport() method), but the compile fails... Does anyone know how to accomplish this in a correct way?
Thanks!
Static text isn't made to be changed programmatically. Why not just change the staticText to a textField and then use a parameter? Change the xml to:
<textField><textFieldExpression><![CDATA[$P{banc}]]></textFieldExpression></textField>
Then set the value of banc programatically and pass it to fillReport()

Is it possible to change position of textField using JasperReports?

I have created .jrxml by using iReport tool and have to dynamically set the x and y position of fields in .jrxml file. How should I do that?
I'm afraid thats not directly possible using reports made in iReport, creating the reports in runtime in Java will solve your issue.