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

Expression Type Cast


Species8372

Recommended Posts

Hello,

 

i am wondering, why it is mandatory to hard cast expression fields. For a developer it is of course not the problem, to write

Code:
new Boolean("a".equals($F{FNAME}))

but for a report-designer, who has absolutely no knowledge of java-syntax?

 

Therefore i wonder why (at least!) for fields like "print, when" it isnt possible to just enter

Code:
[code]"a".equals($F{FNAME})

 

Thats the code the good expression builder creates, so why is it necessary to do this ugly construction to wrap it into the already known Class-Type?

 

It would be great for all fields to have some implicit check, if the field-expression is castable to the required type and then wrap the expression automatically. Or optionally....

 

As it is currently i cannot go to a report-designer employee. They wont take it and prefer the old system.

 

Or maybe i am just to stupid and missed something?

 

Greetings,

 

Species8372

Link to comment
Share on other sites

  • Replies 4
  • Created
  • Last Reply

Top Posters In This Topic

Hi,

 

thankx for your hint. I tried groovy, but honestly it lacks performance. Compiling is 3-6 times slower, filling the report 1.5-2 times slower :-(

 

I always wondered, why in times of JDK1.5 it shouldnt be possible to compile

Code:
(java.lang.Boolean)("bla".equals("bla"«»))

 

So i changed from the default jdt-compiler to the JDK1.5-compiler and it worked how i wanted, without groovy :)

 

There is, however, one major drawback: I am not able to compile from a J2EE-Application as probably the classpath for the external javac-process is not correct.

 

Is there any possible workaround to use the jdk1.5-compiler inside a deployed application on a J2EE-Server? Maybe using javac and the contextClassLoader of my webapp together somehow?

 

Greetings,

 

Markus

Link to comment
Share on other sites

The recommended report compiled is the JDT-based one. This compiler resolves classes using the context class loader, so it is proper for use in J2EE contexts.

 

To compile Java 1.5 code with this compiler, you might need to explicitly set the following properties in your jasperreports.properties file:

Code:

org.eclipse.jdt.core.compiler.source=1.5
org.eclipse.jdt.core.compiler.compliance=1.5
org.eclipse.jdt.core.compiler.codegen.TargetPlatform=1.5

 

Regards,

Lucian

Link to comment
Share on other sites

Thats it! Thank you very much. Fast compile times, no Wrapping of booleans, just what i wanted.

 

The only thing which i dont like very much is the location of the jasperreports.properties in WEB-INF/classes instead of WEB-INF/ where usually all configuration files reside. But i guess i can live with that...

 

Regards,

 

Species8372

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