i-net Clear Reports

Custom report properties

There might be additional properties you wish to set for your own purposes. One example could be that you wish to set the paper size at run-time, right before executing the report, based on a property you set, e.g. via URL.

There is a simple powerful way to do this, which allows you to use as many user properties as you wish. You must place a class named PropertyChecker in your class path which implements the interface com.inet.report.PropertiesChecker - this will cause your class to become the default property checker.

The interface PropertiesChecker has three different methods which must be implemented, each of which will be called at the proper time:

checkProperties(Properties props, Object req)

This method is called right before the engine examines the report file, and passes the properties set for the report as a Properties object, as well as the HTTP servlet request, if there is one (that is, it either passes an HttpServlet object, or null). Using this method, you could for example change the properties object as you wish, adding, removing or editing properties. One example would be to set the location of the report file by calling props.put(“report”,”file:///c:/my-report.rpt”).

checkProperties(Engine engine, Properties props, Object req)

This method is called after the engine has examined the report file, but before the report is rendered, so it allows you to check user properties and call engine methods. For example, you could check for user properties “pwidth” and “pheight” and set the paper size accordingly - engine.setPaperWidth(Integer.valueOf(props.getProperty(“pwidth”)).intValue()).

checkHtmlPageProperties(Properties props)

This method is called before the report servlet creates and sends back an HTML page with the viewer embedded, and allows you to change or add to the default HTML page properties.

Using these methods, you have an incredible amount of influence for customization of reports at run-time simply by implementing these three methods.

See this sample for a example of custom properties class.


i-net software strives to provide accurate product documentation. Please give us your feedback using the form below.
NOTE: This form is for documentation feedback only. For technical assistance, please send an email to clearreports@inetsoftware.de.

 

© Copyright 1996 - 2012, i-net software; All Rights Reserved.