Announcement Announcement Module
Collapse
No announcement yet.
Defining "false" in an XML BeanDefinition for JasperReports Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Defining "false" in an XML BeanDefinition for JasperReports

    Hi All,

    This is a trivial question - I'm sorry to be asking it, but I can't seem to find an answer anywhere. It is probably more of a core container question, but it will be of most use to JasperReports users such as myself.

    I have a bean called "report" as defined below

    Code:
    <bean id="report"
    			class="org.springframework.web.servlet.view.jasperreports.JasperReportsMultiFormatView">
    		<property name="url"><value>/WEB-INF/reports/report.jrxml</value></property>
    		<property name="exporterParameters">
    			<map>
    		    	<entry key="net.sf.jasperreports.engine.export.JRHtmlExporterParameter.IS_USING_IMAGES_TO_ALIGN">
    		        	<value>false</value>
    		      	</entry>
    		    </map>
    		</property> 
    		<property name="contentDispositionMappings">
                <props>
                    <prop key="html">inline; filename=report.html</prop>
                    <prop key="csv">inline; filename=report.csv</prop>
                    <prop key="pdf">inline; filename=report.pdf</prop>
                    <prop key="xls">inline; filename=report.xls</prop>
                    <prop key="xml">inline; filename=report.xml</prop>
                    <prop key="ser">inline; filename=report.ser</prop>
                </props>
            </property>
    	</bean>
    It is a pretty standard JR MultiView report bean, and as you can see I am trying to disable alignment using images.

    Everything works well, except for the "false" in the exporterParameters map. When a JR HTML rendering bean is created, Spring tries to set the IS_USING_IMAGES_TO_ALIGN to "false" and I get a ClassCastException for java.lang.String.

    Ok, so I am defining false incorrectly in the map. I tried Boolean.FALSE and got the same result, so I seem to be missing something fundamental about using <map> in a bean definition. I had a poke around and couldn't find an example of using a boolean in a map in a bean definition.

    My trivial question is: How do I define false here? That is, how do I make it explicit to Spring that I mean boolean false and not "false"? Or if I am waaaay off track, please let me know.

    Thanks for your help,
    Deakin

  • #2
    Ok, after some more trawling, I have the answer - posted here for the future reference of others. It seems so simple now (but it always does right?).

    This what you need:

    Code:
    <property name="exporterParameters">
    			<map>
    		    	<entry key="net.sf.jasperreports.engine.export.JRHtmlExporterParameter.IS_USING_IMAGES_TO_ALIGN">
    		        	<value type="boolean">false</value>
    		      	</entry>
    		    </map>
    		</property>
    The magic is in the type="boolean".

    Cheers,
    Deakin.

    Comment

    Working...
    X