JasperViewer in Windows

I have an issue that is Windows only at this point where I’m using the following code to generate a report using the Jasper Report plugin:

plugins.jasperPluginRMI.jasperReport(currentcontroller.getServerName(),'report.jasper',null,'view',params);

The report generates okay and the report shows up in the JasperViewer application but JasperViewer does not become the foreground application. The user has to activate the JasperViewer app to see the report. The above code is also the last line of the method so I don’t believe any other code is interfering. This is not a problem on the MacOS, only Windows. Any thoughts?

Any of the Servoy guys have any ideas on this?

I have never had this problem using windows (xp pro sp3). So maybe something else is causing your servoy app to become dominant?
Tom

Which version of Servoy and which version of the Jasper plugin do you use?

Does the form that is showing in Servoy grab focus after showing the Jasper Viewer?

Paul

Paul,

This is happening in Servoy 4.1 rc2 and I’m using the latest version of the Jasper plugin (2.1.2).

When the report is generated from the Servoy method, the screen flashes (JasperViewer appears for a split second ) and Servoy remains the active window. The JasperViewer app is displaying the report as expected, but it is in the background, behind the Servoy client app.

So, does the Servoy window grab focus after showing the Jasper Viewer? For example, if you start hitting the tab key after the Jasper Viewer is shown, does something happen on your form in Servoy?

If so, try setting the focus to a field, BEFORE showing the Jasper Viewer in your code.

If not, please file a case with sample solution.

Regards,

Paul

I have some further information and found a way to get around the problem.

The beginning of the method has code that finds a set of records, sorts and loops over the found records to prepare the records for the report this method generates. I found the problem went away when I temporarily disabled that code before the Jasper plug-in call. I couldn’t determine any one piece of code was causing the problem, however, putting in a sleep command for 500 milliseconds cured the problem. I played with lower sleep times and began to experience the problem again, but 500 seemed to be very reliable and a tolerable delay for the user.

It’s as if Servoy is still active in the background while the JasperViewer is being brought to the foreground, then Servoy grabs the focus back.

So Paul, to answer your question, Servoy is definitely the focused application when the problem occurs and I can interact with it immediately.

With this additional information, would you still like me to file a case for this?

Have you tried setting the focus to a specific element BEFORE calling the line of code that shows the JasperViewer?

And if that doesn’t work straight away, adding an additional application.updateUI() BEFORE showing the JasperViewer might do the trick.

Most likely, after ending the code, Servoy automatically sets the focus and thereby pops in front of the JasperViewer. By setting the focus yourself first, you should be able to prevent this.

Paul

I did try setting the focus on a layout element before calling the Jasper plugin and it did not solve the problem.

I will try the updateUI command in place of the sleep as it seems that may be a better solution.

I have alter the code, so the call will return an pointer to the viewer. Now it is possible to bring the viewer in front again. e.g. viewer = plugins.jasper…; vieuwer.setVisible(true). I hope the code changes will be accepted.

Regards, DAnny Richardson

Do you mean you have modified the Servoy Jasper reports Plugin on Google Code?
If so then I would like to know from Servoy the plan they have for integrating this and other changes and subsequent releases.

I took Paul’s suggestion of using an updateUI instead of a sleep command and it appears to solve the problem as well.

It would be nice to not have to add this code to get this to work so the discussion of adding code to the plugin to force it to the foreground may be the best solution.

Thanks to you all for your help!

The plugin code finishes first, then Servoy executes more code, so adding something to the plugin to grab focus when Servoy will grab focus afterwards will not be of any use, I think.

Paul

Yes, that is correct. So the solution is dat the plugin returns an pointer to the viewer. Than after Servoy execute some code, you can force the vieuwer to the foreground.

Danny

Which would be an extra line of code as well, while the application.updateUI() call does the same and is also just one line of code, or?

Paul,

I guess this comes down to the expected behavior of using the Jasper plug-in. When calling the plug-in and when using the ‘view’ option, I would expect JasperViewer to become the foreground window and remain so, which it does currently, except in this case where I performed some actions on the records before the plug-in call is triggered.

If we have to add an extra line of code to insure the JasperViewer window is focused, then that’s fine, the problem is this is undocumented at this point ( as far as I know ) and took a good deal of troubleshooting time to figure out.

We will add this to the sample code.