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

How to set a report element property at runtime


chackem

Recommended Posts

Before we start, I'm a noob and have been looking everywhere but can't seem to find any code snippets that explain how to do this.

 

I would like to be able to pass a color to a subreport as a parameter and set the Backcolor property of several elements with that parameter.

 

My goal is to have all the code in the jrxml. I'd like to know how to reference or set these properties from a print when expression, for example. I believe there should be some way to reference these elements using the element key, but I can't figure it out. Any help would be greatly appreciated.

Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

in the jrxml:

Code:

<parameter name="myColor" class="java.lang.String" />
...
<textFieldExpression class="java.lang.String">$P{myColor}</textFieldExpression>

in your java code:

Code:
[code]Map<String, Object> myMap = new HashMap<String, Object>();
myMap.put("myColor", "FF0000"«»);
...
JasperManager...fill(myJasperReport, myMap, ...);
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...