Create, deploy, and maintain analytic applications that engage users and drive revenue. See a Logi demo

Development Tips

Logi Tutorial: How to Use Definition Plugins to Customize HTML Output

By Natan Cohen | November 14, 2017
Share on LinkedIn Tweet about this on Twitter Share on Facebook

The Logi Analytics platform allows developers to bring their own code and extend their applications however they want. For most use cases, developers can use Logi’s powerful predefined elements to configure the application and meet custom requirements.

But what if you want to alter the generated HTML output before it’s returned to the browser? That’s where Definition Plugins come in. Follow these tips and tricks to use them in your applications…

Definition Plugins to the Rescue

Plugins give you the ability to extend the functionality of your Logi applications through custom code. Plugins are basically pieces of code written in .NET or Java and embedded in a Logi project.

The first decision you must make is when to call your plugin. Special elements are provided for calling plugins; you select which one to use based on events associated with them. A PluginCall element runs a method inside of a plugin and is associated with three events:

  • Load Definition: The plugin is called when the definition file is loaded.
  • Finish Data: The plugin is called when data processing finishes.
  • Finish HTML: The plugin is called just before the HTML response is sent back to the browser or to a report export processor.

How do I use a plugin to make changes to the HTML response?

In this tutorial, we will give an example of how to modify the HTML returned to the client by the Logi server. In the sample screenshot below, you can see how Logi allows a user to enter a search term, and the FinishHTML plugin will highlight the resulting HTML if it finds a match for the search term.

 

Step 1: Write your code. When your plugin has been written and compiled, add the element(s) you need to call it in your Logi application (as outlined below).

The first time you run your Logi application, IIS will load the plugin into memory and it will remain cached there. If you make coding changes to the plugin and want to rebuild it, you’ll need to run stop and restart IIS (run iisreset.exe) first, in order to be able to replace the previous build.

Step 2: Add a Plugin Call (Plugin_Call.Finish HTML in our example below) element to the report definition.

Step 3: Specify Assembly name, which is the DLL of the Filename (.Net only). For Java plugins, instead of specifying the physical path to the JAR file, specify the full package name and class name.

Step 4: Specify Class Type name (.Net only). Leave this attribute blank for Java plugins.

Step 5: Specify Event. In this case, the event is “FinishHTML.”

Step 6: Click Plugin Parameters.

Step 7: Specify ElementID. In this case, it’s a data table.

Step 8: Specify the parameter (text) that will be searched. 

Step 9: Specify the HTML style. On the Visual Studio side, the code looks like this:

NOTE: Every project in Logi has a Bin directory and an rdPlugin DLL (.Net only). In your code, you must reference the rdPlugin DLL and utilize the rdServerObjects class, which allows you to communicate with Logi and make calls in and out of Logi. For Java plugins, you should add an external reference to PluginCaller.jar and utilize the LogiPluginObjects10 class, which is located in your Logi application’s WEB-INF/lib directory.

The code extracts parameters from the rdServerObjects class that is coming from the rdPlugin DLL (.Net only). For Java plugins, you should add a reference to PluginCaller.jar and use the LogiPluginObjects10 class. If a search term is entered, the code will first read the generated HTML from Logi, go through and find the elementID (data table), and search/loop through and highlight the word. It will then write the new HTML that was just updated and send it to the user.

>> Find more tutorials and Logi hacks in our Best Practices Series <<

 

About the Author

Natan Cohen is the Director of Solutions Delivery at Logi Analytics. He's been with Logi for over 13 years and has helped create some of our customers' most successful analytic applications.

Subscribe to the latest articles, videos, and webinars from Logi.