Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 533775
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T09:32:36+00:00 2026-05-13T09:32:36+00:00

Have anyone tried to import user defined classes in jasper report (.jrxml file)? I

  • 0

Have anyone tried to import user defined classes in jasper report (.jrxml file)?
I want to use some (user defined) Util class inside my jasper report to cook some bean attributes. I am using Javabean datasource

Please let me know if you need further clarification.

syntax to import class is

<import value="java.util.HashMap"/>

I want to use

<import value="mypackage.MyUtil" />
 ....
 ....
<field name="myVar" class="java.lang.String">
    <fieldDescription><![CDATA[MyUtil.cook(myData)]]>
    </fieldDescription>
</field>

The simple definition for MyUtil.java could be

package mypackage;
public class MyUtil
{
    public static String cook(String data)
    {
        return data + "_cooked";
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T09:32:37+00:00Added an answer on May 13, 2026 at 9:32 am

    I think I should have tried sufficiently before asking this.

    There is nothing extra needed apart from
    There are two sections in jrxml:
    1. Defining fields from javabean source
    2. Using fields defined in step 1. to populate values in detail band

    I was trying to cook the value of javabean members even before they are used to create fields
    So, jasper was trying to parse that ‘expression’ as javabean member.

    Following is wrong

    <field name="myVar" class="java.lang.String">
         <fieldDescription><![CDATA[MyUtil.cook(myData)]]>
         </fieldDescription>
    </field>
    

    When I used the Util class on field value, it worked.

    <textField>
        <reportElement x="200" y="0" width="100" height="13"/>
        <textElement/>
        <textFieldExpression class="java.lang.String">
             <![CDATA[MyUtil.cook($F{myVar})]]>
        </textFieldExpression>
    </textField>
    

    Thanks
    Nayn

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to implement some friendlier error messages if the user tries to run
I wonder if anyone has any insights into this. I have a bash script
I am having real trouble installing SUDS in python 2.6.4. I have tried to
I have the following code (almost an exact copy of the Chat server example
I am having a problem where in SharePoint 2007 after verifying the profile import
I have an articles entry model and I have an excerpt and description field.
I have a program that logs into a server and issues commands. The results
I have been trying to figure out how to retrieve (quickly) the number of
I'm trying to build a python library for interacting with our RESTful API, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.