PDA

View Full Version : custom function



Anonymous
08-12-2002, 09:34 PM
im trying to create a custom function that subclasses AbstractFunction
i want to add an additional field that will print some string. but the problem is the string is in the session (HttpSession), is there any way to fetch it from there? nyway, the obvious way is to print the string first into the file and then read the file from the function class. im looking for more elegant ways.

Anonymous
08-12-2002, 09:55 PM
and btw, how do i turn off the debug statements? :)
im working with servlets and i dont want jfreereport messing up the console (i miss the exceptions when debugging).

Anonymous
08-13-2002, 09:25 AM
Hi,

to your first question: Put the HttpSession-Object into the ReportProperties of the JFreeReport object, you can query them from within the function.

To turn off the debug-statements, set the SystemProperty "com.jrefinery.report.NoDefaultDebug" to "true" and everything vanishes. In case you use Log4J for logging, you may use
the Log4JLogTarget for logging instead. This one can found at http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/*checkout*/jfreereport/jfreereport-ext/source/com/jrefinery/report/ext/log/Log4JLogTarget.java?rev=HEAD&content-type=text/plain

Have more fun,
said Thomas

Anonymous
08-20-2002, 03:19 AM
thank you! :)

Anonymous
08-20-2002, 05:41 AM
hi again.. i still have problem.. all worked except for this part :

> you can query them from within the function.

heres my custom function :

public class ReportQueryFunction extends AbstractFunction {
....

public void pageStarted(ReportEvent event) {
this.reportQuery = getProperty("reportQuery");
}

i tried this.reportQuery = this.getProperty("reportQuery");
also super.getProperty("reportQuery");

which is jfreereport-object's properties?

---------------
i set the "reportQuery" from the servlet that instantiated the JFreeReport object :

JFreeReport report = new JFreeReport();
report = gen.parseReport("\myxmlfilehere.xml");
report.setProperty("reportQuery", "someStringValue");


--------------------

Anonymous
08-20-2002, 01:34 PM
Hi,

A almost correct.

JFreeReport's functions use their own set of properties to get configured. This is what Function.getProperty() queries. To query a reportproperty you'll have to call:

public void pageStarted(ReportEvent event) {
this.reportQuery = event.getReport().getProperty("reportQuery");
}

(Hint: Have a look at com.jrefinery.report.functions.ReportPropertyFunction, it does what you want. But writing an own implementation is at least a perfect exercise ;-) )

Have more fun,
said Thomas

Anonymous
08-20-2002, 11:02 PM
Taqua, hey thanks again :)
i checked out the demo function, i should have read all the sources
i wasnt expecting its all there already ;P
thanks and have a nice day!