I'm trying to pass a XML group content (I'm using XML as datasource) as a parameter to a java method, I need to get this group in java class, format the tags information (name1 + name2 + name3.....nameN) and return it to the JRXML TextField. I can do it for a simple XML tag, but when I try to do it with a group, It appear as null in java method: My XML:
My method signature: public static String formatNames(Object person) {...}
Debugging the "formatNames" method, the parameter "person" appear as null.
If I change the parameter of textFieldExpression to the field group1.group2 it appear as null too.
If I change the parameter of textFieldExpression to the field group1.group2.person.name it appear the String in the java debug: "John".
The goal is format the names list to show as: "John - Mary - Joseph" in the textFieldExpression, if someone have another way to do it, please, tell me. Thank you
How to pass a XML group as parameter from jasper to java
in Products
Posted
I'm trying to pass a XML group content (I'm using XML as datasource) as a parameter to a java method, I need to get this group in java class, format the tags information (name1 + name2 + name3.....nameN) and return it to the JRXML TextField.
I can do it for a simple XML tag, but when I try to do it with a group, It appear as null in java method:
My XML:
<Group1>
<Group2>
<Person>
<Name>John</Name>
</Person>
<Person>
<Name>Mary</Name>
</Person>
<Person>
<Name>Joseph</Name>
</Person>
</Group2>
</Gropup1>
My JRXML fields declaration:
<field name="group1.group2" class="java.lang.Object">
<fieldDescription><![CDATA[Group1/Group2]]></fieldDescription>
</field>
<field name="group1.group2.person" class="java.lang.Object">
<fieldDescription><![CDATA[Group1/Group2/Person]]></fieldDescription>
</field>
<field name="group1.group2.person.name" class="java.lang.String">
<fieldDescription><![CDATA[Group1/Group2/Person/Name]]></fieldDescription>
</field>
My JRML textField Expression:
<textFieldExpression class="java.lang.String"><![CDATA[com.foo.report.MyReport.formatNames($F{group1.group2.person})]]></textFieldExpression>
My method signature:
public static String formatNames(Object person) {...}
Debugging the "formatNames" method, the parameter "person" appear as null.
If I change the parameter of textFieldExpression to the field group1.group2 it appear as null too.
If I change the parameter of textFieldExpression to the field group1.group2.person.name it appear the String in the java debug: "John".
The goal is format the names list to show as: "John - Mary - Joseph" in the textFieldExpression, if someone have another way to do it, please, tell me.
Thank you