views:

697

answers:

1
<?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="report name" pageWidth="595" pageHeight="842" columnWidth="535" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
<property name="ireport.scriptlethandling" value="0" />
<property name="ireport.encoding" value="UTF-8" />
<import value="java.util.*" />
    <import value="net.sf.jasperreports.engine.*" />
    <import value="net.sf.jasperreports.engine.data.*" />
    <reportFont name="BRH-18" isDefault="false" fontName="BRH Kannada" size="18" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="brhknd.ttf" pdfEncoding="Identity-H" isPdfEmbedded="true"/>
    <reportFont name="BDH-16" isDefault="false" fontName="BRH Kannada" size="16" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="brhknd.ttf" pdfEncoding="Identity-H" isPdfEmbedded="true"/>
    <reportFont name="BRH-14" isDefault="false" fontName="Nudi 01 k" size="14" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Times-Roman" pdfEncoding="Cp1250" isPdfEmbedded="true"/>
    <reportFont name="BRH-12" isDefault="false" fontName="BRH Kannada" size="12" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="C:/WINDOWS/FONTS/brhknd.ttf" pdfEncoding="Identity-H" isPdfEmbedded="true"/>


<parameter name="MaxSalary" class="java.lang.Double"/>
<!--<parameter name="name" class="java.lang.String"/>-->
<field name="NAME" class="java.lang.String"/>
 <!-- <field name="COST" class="java.lang.Double"/> -->
    <background>
     <band splitType="Stretch"/>
    </background>
    <title>
     <band height="79" splitType="Stretch"/>
    </title>
    <pageHeader>
     <band height="35" splitType="Stretch"/>
    </pageHeader>
    <columnHeader>
     <band height="61" splitType="Stretch"/>
    </columnHeader>
    <detail>
     <band height="125" splitType="Stretch">
      <staticText>
       <reportElement x="12" y="16" width="100" height="20"/>
       <textElement>
        <font isUnderline="true"/>
       </textElement>
       <text><![CDATA[1)Prpoerty tax1]]></text>
      </staticText>
      <rectangle>
       <reportElement x="12" y="36" width="543" height="60"/>
      </rectangle>
      <line>
       <reportElement x="14" y="56" width="541" height="1"/>
      </line>
      <staticText>
       <reportElement x="29" y="42" width="100" height="20"/>
       <textElement/>
       <text><![CDATA[NAME:]]></text>
      </staticText>
      <line>
       <reportElement x="288" y="31" width="1" height="65"/>
      </line>
      <textField>
       <reportElement x="356" y="33" width="100" height="20"/>
       <textElement textAlignment="Left" verticalAlignment="Middle" rotation="None" lineSpacing="Single">
         <font reportFont="BRH-14"/> 
    <!-- <font fontName="BRH Kannada" pdfFontName="C:Windows/Fonts/brhknd.ttf" size="12" isBold="true" isItalic="false" isUnderline="false" isPdfEmbedded ="true" pdfEncoding ="Cp1252" isStrikeThrough="false" />-->
        </textElement>
       <textFieldExpression class="java.lang.String"><![CDATA[$F{NAME}]]></textFieldExpression>
      </textField>
      <!-- <textField>
       <reportElement x="381" y="61" width="100" height="20"/>
       <textElement/>
       <textFieldExpression class="java.lang.Double"><![CDATA[$F{COST}]]></textFieldExpression>
      </textField>  -->
    <textField>
       <reportElement x="381" y="61" width="100" height="20"/>
       <textElement/>
       <textFieldExpression class="java.lang.Double"><![CDATA[$P{MaxSalary}]]></textFieldExpression>
      </textField>
      <staticText>
       <reportElement x="132" y="72" width="100" height="20"/>
       <textElement/>
       <text><![CDATA[COST]]></text>
      </staticText>
     </band>
    </detail>
    <columnFooter>
     <band height="45" splitType="Stretch"/>
    </columnFooter>
    <pageFooter>
     <band height="54" splitType="Stretch"/>
    </pageFooter>
    <summary>
     <band height="42" splitType="Stretch"/>
    </summary>
</jasperReport>
A: 

Maybe it is a little late. I tried using your jrxml file and it works.

public class TestJasperStackOverflow {

/**
 * @param args
 */
public static void main(String[] args) {
 JasperPrint jp = null;
 String templateName = "testStackOverflow.jasper";
 HashMap parameterMap = new HashMap();         
 parameterMap.put("MaxSalary", Double.valueOf(1100.00));
 try {
  jp = JasperFillManager.fillReport(templateName, parameterMap, new JRDataSource() {

   int i;
   @Override
   public boolean next() throws JRException {
    System.out.println("next " + i++);
    if(i == 10)
     return false;
    else
     return true;
   }

   @Override
   public Object getFieldValue(JRField arg0) throws JRException {     
    return "MyName";
   }
  });
 } catch (JRException e) {
  e.printStackTrace();
 }

 JasperViewer jasperViewer = new JasperViewer(jp, false);
 jasperViewer.setVisible(true);

}}

What you return from getFieldValue method?

Chobicus