Report initial load reportLoading finished but report blank

Having an issue where I am printing multiple reports at a time.
I’m using the reportLoading flag to check whether the report is ready to print:

[code]if event.propertyName == “reportLoading”:
reportLoading = event.source.reportLoading

window = event.source.parent.parent

if reportLoading == True:
	window.reportNotReady = True

if window.reportNotReady == True and reportLoading == False:
	window.reportReady = True[/code]

This is working fine generally, except for the very first load from a new client or after updating the client.
I am getting the flag reportReady as True but the report is printing blank (the report is formed fine with the defaults but the variable sections are blank)

The following reports print fine and the flag works as expected.

I have a work around which is to open and close the first report before trying to print it but its a little bit horrible.

Any thoughts?

Any chance you can post the window so we can take a look?

I can’t send the actual screen over unfortunately, I will have a look at putting together a mock up when I have a chance.


I’ve put together a lash up of what’s happening, it’s not actually how we are doing it as we are simply passing an id to the report and loading data from a database, also the report if more complex.

In fact I am getting the opposite affect now… The very first time the script is run either after a project update or a new client is opened the reportReady fires incorrectly. Every time after it will fire fine.

report printing test.proj (24 KB)

:scratch: Where does the report actually get printed?

Without looking at your “lash up” project, shouldn’t you be looking at the “event.newValue” rather than “event.source.reportLoading”?

Just my two-bob’s worth (…for what it’s worth) :smiley:

Those two value should be equivalent. I think he just needs an invokeLater, maybe with a little bit of “fudge time” in there on his call to print. But I couldn’t find the call to print…

The printing all happens in the ‘action performed’ of the print button. The call to print is report.print(None, 0).

I am using invokeLater, we are worried about slow machines or connections. I am currently using some loops with delays say 200ms to check the window has been found and then the reportLoading has finished.

We are trying to make this more robust by using the event.source.reportLoading property to check that the report has in fact finished loading and not guessing.

The problem seems to be that the event fires inconsistently. In our initial tests of the property it seemed to always fire:
False, (report not loading?)
True, (report is loading?)
False (report finished loading?)

Apart from the first time the report has loaded it seems to only fire False. Maybe somehow I am missing the other event fires? Or thinking about this wrong?

Ok, I looked into this, and here’s what’s going on. You’re essentially just missing the first reportLoading=true that you’d expect, because it happens before your property change listener script is installed.

There are various steps to opening a window, and before the script event listeners are registered, the components get deserialized which is what causes the first reportLoading=true to happen (that you’re missing). Because report loading is asynchronous, you’re catching the reportLoading=false caused by that first event. Then a binding comes back with a value, which causes the second pair of reportLoading=true, reportLoading=false.

I’ve made some changes as of 7.5.3 that make the events appear as you expected them, but you’ll still get (at least!) two pairs of loading true->false. Because of this, I’d do something like the following:

Each time the reportLoading=false happens, record the timestamp (via java.lang.System.currentTimeMillis(), perhaps). Maybe put this number on a property on the root container or something. Only print when reportLoading=false AND the timestamp is at least 1000millis old (or something).