Java Tag Library

Another way of embedding a Corda® image in a Java* Server Page (JSP) is via the Corda Embedder Java Tag Library. Using the Corda Embedder with tag libraries is almost exactly like using it with Java. Although the code looks a lot different, the processes are the same.

Embedding a Corda image into a JSP via the Corda Embedder Java Tag Library can be broken down into the following steps:

The example code at the end of this section shows you how to embed a Corda image in a JSP using the Java Tag Library.

Note: This documentation assumes that you are familiar with Java tag libraries.

Installing the Java Tag Library

Before importing the Corda Embedder library into a JSP, first make sure that the CordaEmbedder.jar file, located in the dev_tools/embedder/java folder, is in the classpath for the Web application. For more informaiton, see Java Application Servers in the Corda 7 Install and Administration manual.

Some older Java application servers need to explicitly install the Java tag library for the Web application. If the sample code in this section fails to work, follow the instructions outlined in Java Tag Library in the Corda 7 Install and Administration guide.

Delimiting the Code For a Corda Image

Delimit tag library code for the Corda image with <ctl:Corda> and </ctl:Corda> tags. For example:

<ctl:Corda imageTemplate="image_templates\examples\bar.itxml">

<ctl:addHTMLTable graph="graph"/>...

</ctl:Corda>

Place the Corda Embedder code within one <ctl:Corda> tag. The majority of Corda Embedder settings are set as attributes of the <ctl:Corda> tag, but some are properties contained by this tag.

Syntax Notes

Most of the example code in this Reference assumes that you are using the Java Corda Embedder. Thus, you must convert the example code syntax for use with Java Tag libraries. When doing this, consider the following:

Attributes

For the most part, Corda Embedder attributes can be translated into Corda Tag Library syntax by simply creating an attribute in the <ctl:Corda> tag with the same name as Corda Embedder attribute that you want to use.

<ctl:Corda externalServerAddress="http://<server_address>:2001" internalCommPortAddress="http://localhost:2002" />

One exception to this is the pcScript attribute, which (because it can grow so big), is represented with the <ctl:pcScript> property, contained by the <ctl:Corda> tag.

<ctl:Corda>

<ctl:pcScript> graph.setCategories(Red)... </ctl:pcScript>

</ctl:Corda>

Methods

For the most part, translate Corda Embedder methods into Corda Tag Library syntax by creating a property in <ctl:Corda> with the same name as the Corda Embedder method you want to use. Then, pass the parameters of the method as attributes to the tag. For example:

<ctl:Corda

<ctl:method param="value" param2="value2" />

</ctl:Corda>

However, this is not always the case. The addITXML, setMapData and loadMapData methods follow these rules except for the parameters setting the ITXML or the data. Since these parameters can be large, they are specified as a contained property. For example:

<ctl:setData graph="graph">

Red,Blue,Green...

</ctl:setData>

Instantiating a Corda Embedder Object

To instantiate a Corda Embedder object, use code similar to the following:

<%@ taglib uri="com.corda.taglib" prefix="ctl" %>

Setting the Server Information

Corda Embedder needs to know two Corda Server™ addresses: the address that the Web client uses to access Corda Server (externalServerAddress), and the address that Corda Embedder uses to access Corda Server (internalCommPortAddress). For more information about determining these addresses, see Identifying Server Addresses.

For example, if Corda Embedder communicates with Corda Server at 10.0.1.1:2002, and Web clients request images from http://myserver.mycompany.com:2001, include the following attributes in the <ctl:Corda> tag:

<ctl:Corda externalServerAddress="http://myserver.mycompany.com:2001" internalCommPortAddress="http://10.0.1.1:2002" />

Setting Image Information

After specifying server address information, give Corda Embedder some information about the Corda image you want to embed.

There are numerous Corda Embedder commands to specify image information, which are consistent in all Web application environments (with the exception of several syntax differences, as previously explained in Syntax Notes). Thus, it is unnecessary to discuss each of these commands individually at this time.

The table below provides links to more information about Corda image features and components:

Topic

Where To Go

Annotations

Data Annotations in the Corda Builder™ User Guide

Content Delivery / Presentation Control

Image Deployment Issues and Descriptive Text Settings

Data

Connecting to Data Files and Connecting to Databases

Drilldown

Building Drilldown

Graph or Map Customization

Dynamically Customizing Graphs and Maps

Image Size & Format

Changing the Image Format and Changing Image Size

Writing the Image to a Web Page

When you are ready to write the image to a Web page, close the <ctl:Corda> tag. The Corda Embedder tag library then writes the image to the Web page.

Complete Example Code

The code sample below demonstrates embedding a Corda image in a Java Server Page with the Java Tag Library.

Note: To produce an example map instead of a graph, replace examples\bar.itxml with examples\map\australia_combo.itxml in the code designating the Image Template file.

Embedding a Corda Image in a Java Server Page (Tag Library)

<%@ page language="java" contentType="text/html" %>

<%@ taglib uri="com.corda.taglib" prefix="ctl" %>

<html>

<head>

<title>My First Embedded Image</title>

</head>

<body>

<h1>This is your Image</h1>

<hr />

<!-- Begin Embedder Code -->

<ctl:Corda externalServerAddress="http://<server_address>:2001" internalCommPortAddress="http://localhost:2002" imageTemplate="image_templates\examples\bar.itxml" width="600" height="400">

<ctl:pcScript>title.setText(Hello World)</ctl:pcScript>

</ctl:Corda>

<!-- End Embedder Code -->

<hr />

<p>If you see an image above, congratulations.  You have successfully embedded your first image.</p>

</body>

</html>