Jump to content

Using custom classes as parameter types


clemens_august

Recommended Posts

Hello!

I am running and developing against JaspersoftStudio-6.3.0.final. I use the Windows (64 Bit) and the Linux (64 Bit) versions. In both cases JDK 8u102

In the course of extending Jaspersoft Studio with own datasource implementations by an Eclipse plugin, I would like to use my own classes as parameter types. In this special case, it is an enum: net.august.clemens.TimeLevelEnum. Here, I come across 2 problems.

First, in the parameter property window, net.august.clemens.TimeLevelEnum is not available when opening the class browser (clicking the '...' next to the class name input). I have to input "net.august.clemens.TimeLevelEnum" by hand. Nevertheless, when running the report, I get a nice combo box with the enum members as a parameter prompt, thus the class can be used. My question is there maybe an extension point to "register" custom classes for the parameter properties dialogue?

Second, I get an error when filling the report with a parameter of type net.august.clemens.TimeLevelEnum as input for a text field. But I get this error only, when running the Linux version, under Windows the report fills just fine with the selected member of net.august.clemens.TimeLevelEnum.

Is this due to a bug in the software, or is there a likely pointer to something I am not doing properly? It would be very nice to be able to use fully integrated custom types as parameters.

Greetings, Clemens

Here is the stack trace:

net.sf.jasperreports.engine.JRException: net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression for source text: $P{Timelevel}
        at com.jaspersoft.studio.editor.preview.view.control.ReportControler.fillReport(ReportControler.java:537)
        at com.jaspersoft.studio.editor.preview.view.control.ReportControler.access$20(ReportControler.java:512)
        at com.jaspersoft.studio.editor.preview.view.control.ReportControler$5.run(ReportControler.java:393)
        at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
Caused by: net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression for source text: $P{Timelevel}
        at net.sf.jasperreports.engine.fill.JREvaluator.evaluate(JREvaluator.java:290)
        at net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:616)
        at net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:584)
        at net.sf.jasperreports.engine.fill.JRFillElement.evaluateExpression(JRFillElement.java:1164)
        at net.sf.jasperreports.engine.fill.JRFillTextField.evaluateText(JRFillTextField.java:526)
        at net.sf.jasperreports.engine.fill.JRFillTextField.evaluate(JRFillTextField.java:510)
        at net.sf.jasperreports.engine.fill.JRFillElementContainer.evaluate(JRFillElementContainer.java:381)
        at net.sf.jasperreports.engine.fill.JRFillBand.evaluate(JRFillBand.java:500)
        at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillTitle(JRVerticalFiller.java:311)
        at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:247)
        at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:115)
        at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:580)
        at net.sf.jasperreports.engine.fill.BaseFillHandle$ReportFill.run(BaseFillHandle.java:123)
        at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassCastException: java.lang.String cannot be cast to net.august.clemens.TimeLevelEnum
        at Blank_A4_1474279094917_9823.evaluate(Blank_A4_1474279094917_9823:175)
        at net.sf.jasperreports.engine.fill.JREvaluator.evaluate(JREvaluator.java:276)
        ... 13 more

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Additional infomation -- when adding a default expression, i.e., a concrete enum member, the report fills under Linux as well.

However, when in the parameter prompt choosing a different value, the error occurs. Maybe an issue with passing values from the dialogue?

Still not understood, why there is the discrepancy in behaviour.

Link to comment
Share on other sites

I can answer the question about the custom class not being browseable myself. The dialogue for browsing the classes is the standard Eclipse Type Selection Dialog. Thus, the problem is not Jaspersoft specific.

If the classes are on the project's build path, they can be browsed. So one has to add them. Whether this can be done programmatically, I have to find out.

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