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

How to add check box to jrxml content.


venkatgvr

Recommended Posts

 Hi,

I'm unable to find an option in ireport tool to add a check box to jrxml content.

my requirement is to add check box in jrxml content and at run time when I generate the pdf report out of jrxml,

I should be able to pass data which specifics whether the check box should be checked or not.

i.e (for instance for name field I could able to add a field and text box at same time at run time I'm able to pass the name while generating the report similarly I'm expecting same for my check box funtionlity).

please let us know the possible solution.

Any help is highly appreciated.

 

Thanks

 

Link to comment
Share on other sites

  • Replies 7
  • Created
  • Last Reply

Top Posters In This Topic

 

Hi,

Thank you for your quick reply.

Please can you post some sample java code to  "determine which image to display on the report." at run time as post in below thread.

Right now I'm using below sample code to pass data to text field at runtime, where name and address are text fields specified in jrxml.

1) Java Code

2) Jrxml content

Any help is highly appreciated.

Thanks.

Code:
1)<========================Java Code ==============================>String path = "D:\\dynamic_data";HashMap map = new HashMap();map.put("name", "tcs");map.put("address", "hyd");jasperReport = JasperCompileManager.compileReport(path+".jrxml");jasperPrint = JasperFillManager.fillReport(jasperReport, map, JasperExportManager.exportReportToPdfFile(jasperPrint, path+new JREmptyDataSourc());2)<=================JRXML Content======================><?xml version="1.0" encoding="UTF-8"?><jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name=".jrxml" pageWidth="595" pageHeight="842" columnWidth="495" leftMargin="57" rightMargin="43" topMargin="43" bottomMargin="43">	<queryString language="SQL">		<![CDATA[]]>	</queryString>	<field name="name" class="java.lang.String"/>	<field name="address" class="java.lang.String"/>	<variable name="name" class="java.lang.String"/>	<title>		<band height="45" splitType="Stretch"/>	</title>	<pageHeader>		<band height="45" splitType="Stretch"/>	</pageHeader>	<columnHeader>		<band height="25" splitType="Stretch"/>	</columnHeader>	<detail>		<band height="73" splitType="Stretch">			<staticText>				<reportElement x="106" y="12" width="62" height="15"/>				<textElement/>				<text><![CDATA[Name]]></text>			</staticText>			<textField isBlankWhenNull="false">				<reportElement x="224" y="12" width="72" height="15"/>				<textElement/>				<textFieldExpression class="java.lang.String"><![CDATA[$F{name}]]></textFieldExpression>			</textField>			<staticText>				<reportElement x="106" y="42" width="62" height="13"/>				<textElement/>				<text><![CDATA[Address]]></text>			</staticText>			<textField isBlankWhenNull="false">				<reportElement x="224" y="41" width="72" height="15"/>				<textElement/>				<textFieldExpression class="java.lang.String"><![CDATA[$F{address}]]></textFieldExpression>			</textField>		</band>	</detail>	<columnFooter>		<band height="45" splitType="Stretch"/>	</columnFooter>	<pageFooter>		<band height="45" splitType="Stretch"/>	</pageFooter>	<lastPageFooter>		<band height="45" splitType="Stretch"/>	</lastPageFooter>	<summary>		<band height="45" splitType="Stretch"/>	</summary></jasperReport>
Link to comment
Share on other sites

  • 8 months later...

Another way is to use unicode:

...

  <field name="COLUMN_4" class ="java.lang.Boolean" />

...

<textFieldExpression class="java.lang.String">
     <![CDATA[$F{COLUMN_4} ? "u2611" : "u2610"]]>
</textFieldExpression> 

...



Post Edited by lenalex at 08/26/2012 19:51
Link to comment
Share on other sites

  • 1 year later...
This does not print a character with unicode u2611 (checkbox), but the string "u2611" itself; at least not with JR 5.5.0. I am using JasperStudio. I also noted that when I enter the "class=java.lang.String" in the textFieldExpression, the JasperStudio report designer automatically removes that attribute. I am using the ☐/☑ characters directly, not unicode encoded, works fine as well.
Link to comment
Share on other sites

  • 1 year later...
  • 3 years later...
  • 1 year later...

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...