Can we call a java function from jrxml file If yes any example to acheive this?

0

..

thinking.alone2501's picture
Joined: Sep 21 2019 - 12:49am
Last seen: 3 weeks 5 days ago

1 Answer:

0

Just create a class like

package de.cbox.test;
import java.lang.*; 
 
public class MyTest {
 
   public static String getSomeStuffByField(String fieldContent) {
 
      return "SomeStuffF filled or modified with your field content: " + fieldContent;
 
   }
 
}

create a jar for that class and put that into your classpath.

From within your jrxml file you could then easily access that method within an expression:

de.cbox.test.MyTest.getSomeStuffByField($F{YourFieldFromJRXML})

if you are too lazy to write the full package path always you also can add the package to the "imports properties" in your jrxml and then just use the shorter syntax:

MyTest.getSomeStuffByField($F{YourFieldFromJRXML})

and voilá it will print the result of that static method.

hth + regards

C-Box

C-Box's picture
1964
Joined: Jul 19 2006 - 5:58pm
Last seen: 3 days 2 hours ago
Feedback
randomness