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

How to add into server "global" scriptlet for all reports?


aprilsw
Go to solution Solved by lucianc,

Recommended Posts

I want to add scriptlet for all report on JasperServer. So i made a 
public class MyStandardScriptletFactory implements ScriptletFactory
and public class MyStandardScriptlet extends JRDefaultScriptlet
and report withOUT any custom scriptlets. 
put JAR into tomcat/webapps/jasperserver/WEB-INF/lib/

Run repot and MyStandardScriptlet isnt work (called).
What i am missing?
How to turn on logs on server to trace loading of JARs?
 

i try to make this thing:

We can associate scriptlets in another way to reports, which is by declaring the scriptlets globally. This makes the scriptlets apply to all reports being filled in the given JasperReports deployment. This is made easy by the fact that scriptlets can be added to JasperReports as extensions. The scriptlet extension point is represented by the net.sf.jasperreports.engine.scriptlets.ScriptletFactory interface. JasperReports will load all scriptlet factories available through extensions at runtime. Then, it will ask each one of them for the list of scriptlets instances that they want to apply to the current report that is being run. When asking for the list of scriptlet instances, the engine gives some context information that the factory could use in order to decide, which scriptlets actually apply to the current report.

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

  • Solution

What you need to do is to register your scriptlet factory as an extension.

To do that you'll first need to implement an extension factory like this:

public class MyStandardScriptletExtension implements ExtensionsRegistryFactory {    @Override    public ExtensionsRegistry createRegistry(String registryId, JRPropertiesMap properties) {        return new SingletonExtensionRegistry<>(ScriptletFactory.class, new MyStandardScriptletFactory());    }}[/code]

And then create a file called jasperreports_extension.properties in the root of your jar with the following contents:

net.sf.jasperreports.extension.registry.factory.my.standard.scriptlet=<my.package>.MyStandardScriptletExtension[/code]

 

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