Introduction
This article shows some quick tips as to how to embed the Jaspersoft Ad-hoc interface into another web application. It's not a complete guide, just tidbits about embedding
Decorations
There's a lot of "boilerplate" that comes with the standalone application that we need to get rid of if we want to integrate the ad-hoc interface.
There are two methods we can use to hide decorators - using a built in URL paramter called decorate=no - this is simple because it's already integrated into the aplication. The other method is via a theme - it allows for more options to customize the interface
Decorate=no
This is simple enough to use - just append &decorate=no to the URL used to construct the call:
But there are limitations to this - for example, if the user clicks on any link, decorate=no will be lost and the boilerplate will be put back on, so the best way is around themes
Theme
Themes are best described in Chapter 5 of the JasperReports Admin Guide, this article won't get into too much detail about them. Just the tequnique used. We create a tiny theme that hides deocrations in the overrides_custom.css file, like this:
/* overrides_custom.css */
body { background-color: white; background: none;} #banner { background: none; display:none;} #frame { top: 0;} #frameFooter { display:none !important;}
Here's a very short video on how to create a theme from that CSS file
So now that you know how to create a theme, you can simply set it by URL, gives you infinite level of control and it will persist in the user's session, so if they click somewhere the theme will be kept. You can also use this to match the styling of the application that you're embedding into.
And here's what that might look like:
URLs
Now comes the fun part, what URLs will I use to render these pages?
Embedding a Single Analysis View (in Edit Mode)
It's not as simple as you think to embed a single view - the URL that is created when you click on a view is generated at the moment you click on it (so you'll need a flowExecutionKey and things like that). There's a method for building URLs though, don't worry!
It's simple enough, you just simply need to pass a resource ID to the adhocFlow. So first you will need to get the resource ID of an existing view. Here's a little video explaining how you can find the resource ID of a view.
Once you have the resource URL, you can generate the view:
http://localhost:8080/jasperserver-pro/flow.html?_flowId=adhocFlow&resource=/public/Samples/Ad_Hoc_Views/1_Geographic_Results_by_Segment&theme=embed
Embedding a Single Analysis View (in View mode)
Sometimes you don't want to throw the user right into the view, give them a friendlier "report view" first and they can edit it by pressing the "eyeball" icon
http://localhost:8080/jasperserver-pro/flow.html?_flowId=adhocFlow&resource=/public/Samples/Ad_Hoc_Views/1_Geographic_Results_by_Segment&theme=embed&viewReport=true
Example:
Embedding Editor Screen
This one is simple, just use this URL to get to the datasource chooser screen: http://localhost:8080/jasperserver-pro/flow.html?_flowId=adhocFlow
Recommended Comments
There are no comments to display.