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

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


thinking.alone2501
Go to solution Solved by C-Box,

Recommended Posts

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

  • Solution

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;   }}[/code]

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})[/code]

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})[/code]

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

hth + regards

C-Box

Link to comment
Share on other sites

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