dunham Posted December 16, 2016 Share Posted December 16, 2016 HiI have multiple reports and want to be able to set the background color ("backcolor") of a textfield element via parameter. (Parameter: "customColor: #333333")This parameter has a default value of "#000000" (black), when I define a custom color through my Java program which kicks of the report I want all reports to use that color as background.I do not want to use styles because I want to be able to change the color easily (not having to go through all reports and changing the conditional style). I want to set this parameter once in all reports and then not have to change the templates again when I decite to use another color.Can this be done? (backcolor="$P{customColor}" does not work:(If not what would be the best approach?<textField><reportElement mode="Opaque" x="2" y="16" width="580" height="18" forecolor="#333333" backcolor="#000000" uuid="e111bb79-af6d-4d24-896e-271220ef1f59"/><textElement verticalAlignment="Middle" markup="none"><font fontName="SansSerif" size="14" isBold="true"/><paragraph leftIndent="2"/></textElement><textFieldExpression><![CDATA[$P{TRANSLATE_SCRIPTLET}.translate("lKundenauszug")]]></textFieldExpression></textField> [/code] Link to comment Share on other sites More sharing options...
lucianc Posted December 16, 2016 Share Posted December 16, 2016 See http://jasperreports.sourceforge.net/config.reference.html#net.sf.jasperreports.style.{style_property_suffix}What you need is<reportElement ...><propertyExpression name="net.sf.jasperreports.style.backcolor">$P{customColor}</propertyExpression></reportElement>[/code]Regards,Lucian Link to comment Share on other sites More sharing options...
dunham Posted March 1, 2017 Author Share Posted March 1, 2017 Thank you lucianc for your replyI have created a test report with my element:<textField> <reportElement key="" x="-13" y="170" width="580" height="18" uuid="77c11b23-d15f-4a27-a4bb-c00812d9656b"> <propertyExpression name="net.sf.jasperreports.style.backcolor"><![CDATA[$P{colorcustom}]]></propertyExpression> </reportElement> <textElement verticalAlignment="Middle" markup="none"> <font fontName="SansSerif" size="14" isBold="true"/> <paragraph leftIndent="2"/> </textElement> <textFieldExpression><![CDATA["color: " + $P{colorcustom}]]></textFieldExpression> </textField>[/code]I set this parameter to "#000000" however the background is still white (should be black).What am I doing wrong? Link to comment Share on other sites More sharing options...
lucianc Posted March 2, 2017 Share Posted March 2, 2017 Set mode="Opaque" for the element.Regards,Lucian Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now