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

Dynamically change the fonts and color


2004 IR Help

Recommended Posts

By: msa - amysore

Dynamically change the fonts and color

2005-03-29 12:10

Hi,

 

I need to dynamically change the background color and font style(bold etc) of the text field depending on values returned from a List object.

 

I am using a CustomDataSource and setting the background color and font style in the xml template. I need to change some of these values dynamically.

 

Any ideas on how this can be done.

How do I obtain a handle to the JRTextField or the JRBaseTextField elements. These classes have getter and setter methods for manipulating these attributes.

 

Should I create the template design on the fly too using JasperDesign or Can this be done using scriplets?

 

Any ideas are appreciated.

 

Thanks

 

 

 

 

 

 

 

 

By: Vinod Kumar Singh - vinodsingh

RE: Dynamically change the fonts and color

2005-03-30 01:04

Dynamic Element Formatting

 

http://jasperreports.sourceforge.net/tips.tricks.html

 

 

 

 

By: Paul Meshkovsky - meshpaul

RE: Dynamically change the fonts and color

2005-03-31 09:09

Check this thread. I was using iReport. But it all should apply

 

http://sourceforge.net/forum/forum.php?thread_id=1257412&forum_id=217623

Link to comment
Share on other sites

  • 5 years later...
  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

These links are broken.

 

I'm looking for xml sample to show how styles are applied. Inline is fine. I used the following code(added the style='xx' in an attempt to overcome a SaxParse error I'm getting).:

org.xml.sax.SAXParseException: Element type "style" must be declared.
      at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195)
      at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:131)
      at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:384)
      at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:318)
      at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.handleStartElement(XMLDTDValidator.java:1929)
 I've tried several variations of this with no success. Our Jasper version is 0.6.0 as we are expanding an earlier implementation. We are planning to upgrade in a separate effort.

** Code attached **Using: DOCTYPE jasperReport PUBLIC "//JasperReports//DTD Report Design//EN" "http://jasperreports.sourceforge.net/dtds/jasperreport.dtd">

Can we point to explicit version of the DTD? Is this necesary?

 

<!

Code:
<!--  Atempting to get alternating row colors --><jasperReportname="nccDetail"columnCount="1"printOrder="Vertical"orientation="Landscape"pageWidth="1670"pageHeight="725"columnWidth="1640"columnSpacing="0"leftMargin="15"rightMargin="15"topMargin="15"bottomMargin="15"whenNoDataType="NoPages"isTitleNewPage="false"isSummaryNewPage="false"><property name="ireport.scriptlethandling" value="0"/><property name="ireport.zoom" value="1.0"/><property name="ireport.x" value="0"/><property name="ireport.y" value="0"/><style style="someStyle" name="rowColr" mode="Transparent" isDefault="true" pen="None" backcolor="#FFFFFF"><conditionalStyle><conditionExpression><![CDATA[$V{REPORT_COUNT}%2 == 1]]></conditionExpression><style style="none" backcolor="#99CCFF"/></conditionalStyle></style>**********<textField pattern="" isBlankWhenNull="false">  <reportElement x="880" y="0" width="60" height="15" style="rowColr"/>  <textElement textAlignment="Center"/>  <textFieldExpression><![CDATA[$F{columnName}]]></textFieldExpression></textField>
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...