Publishing Dynamic Image Template Files with the Sample Code Editor

When using Corda® Builder™ to create dynamic Corda images with Corda Server™, you can jump-start the Web deployment process by letting Corda Builder automatically generate the code needed to embed a dynamic Corda image in a Web page. Simply load or create an Image Template file, and then click the Sample Code button in the Corda Builder toolbar. The Sample Code Editor generates a complete example Web page for the Corda image.

Important: Save the Image Template file before creating the sample Web page. If Corda Server is running on a different computer, save the Image Template file to the computer running Corda Server.

The Sample Code Editor generates example code for a variety of environments (JSP, ASP, PERL, PHP, ColdFusion*, .NET, and standard HTML) using Corda Embedder to create and display the Corda image within the Web page. The Sample Code Editor also lets you to specify important variables, such as the image type and a server address.

The generated sample code can be saved directly to a Web server, where it works immediately; however, it is more usual to further customize this code before publishing the Corda image. Either way, the Sample Code Editor can save you a lot of time when generating code. It's also a great learning tool.

Note: Except for the ASP, ColdFusion and HTML options, a Corda Server administrator needs to install Corda Embedder for the example code to work. For information about installing Corda Embedder, see Installing Corda Embedder in the Corda 7 Install and Administration Guide.

Sample Code Options

There are several buttons and options in the Sample Code interface. The table below describes each item.

 

Item

Description

Sample code for

Select the target environment for the sample code from the drop-down list.

Server URL

Specifies the Corda Server address. If Corda Server is running locally, leave this value as http://<server_address>:2001. If you don't know where Corda Server is running, ask the Corda Server administrator, or see Identifying Server Addresses in the Corda 7 Developer Reference.

Comm Port

Specifies the Corda Server's comm port address. If the Corda Server is running locally, leave this value as http://localhost:2002. If you don't know where Corda Server is running, ask the Corda Server administrator, or see Identifying Server Addresses in the Corda 7 Developer Reference.

Output Type

Specifies the output type for the Corda image. Options include JPEG, FLASH, and SVG*.

Use Best Image Fallback

Enables best image fallback, which detects the plug-ins a browser has and allows the Web browser to always show a Corda image using the best possible image format supported by that Web browser. For more information see Best Image Fallback in the Corda 7 Developer Reference.

Show Database Connectivity Sample Code

When selected, this option inserts sample code for database connectivity. This code refers to the CordaSamples database that is installed by default on most Windows* systems. In fact, if you use it on a Windows system, the sample page/Web application actually connects to the CordaSamples database. However, most database programmers find it fairly easy to modify this code to connect to their own database.

To learn more about the CordaSamples database, see Corda 7 Sample Databases in the Corda 7 Install and Administration Guide.

Select Code File

(for ASPNET samples)

Shows either the HTML source for the Web page (the .aspx file), or the .NET code behind the Web page (the .aspx.cs or .aspx.vb file).

Server Commands

(for HTML samples)

Specifies that these pages use server commands instead of Corda Embedder to request a Corda image. This allows you to specify the method used to send server commands to Corda Server.

  • Appended to the URL: Server commands are sent in the same request used to get the image from Corda Server. This is the easiest way to do things, but it may not work with some Web browsers if the request grows longer than 512 characters.

    When using this method, URL-encode the request so that the browser properly transmits it to Corda Server. Select Include Javascript* to URL-encode request string to include a Javascript function to do this encoding for you.

  • Returned from this URL: Generates a server command file based upon a server command file located on another Web server, or generated by a Web application on another server. Specify the URL to the server command file in the field to the right.

  • In this server-side file: Specifies the location of a server command file for this image on Corda Server. Specify the file name (relative to Corda Server's <document_root> directory) in the field to the right.

Save Preferences

Saves the sepcified settings for Server URL, Comm Port, Code type and Image Type, as default Sample Code preferences.

Save Code to File

Saves the displayed sample code to a file.

Copy Code to Clipboard

Copies the sample code displayed in the Sample Code window to the system clipboard.

Save Sample Data File(s)

(for map images only)

Saves a sample data table to the CordaSamples database. This sample data table is compatible with the map you are currently using. If the CordaSamples database is not installed, Corda Builder saves the data as a CSV file in <document_root>\examples\data (see the Show Database Connectivity Sample Code option above).

 

Testing The Image Template File

The following process tests an Image Template file with the example code generated for the JSP Corda Embedder. You must have Corda Server running locally for this to work as described.

Note: These instructions can be used with most Web application environments (ASP, Java*, etc.), by saving the file to the appropriate Web application server.

To test the Image Template file with the Java Corda Embedder

  1. Start Corda Builder.

  2. Load or create an Image Template file.

  3. Click the Sample Code button on the toolbar.

  4. In Sample Code For, select JSP (Java embedder).

  5. Select Save Code to File.

  6. Specify a file name and save it.

    To serve this page from a Web server, save it to (or subsequently upload it to) a Web-enabled directory.

  7. Start Corda Server locally.

  8. View the Web page that you saved in step 6 in a Web browser.

    If you don't see a Corda image, make sure Corda Server has been started, and that it is running at http://<server_address>:2001. If it is running on a different machine, change the Server URL value in the sample code dialog, and upload the Image Template file to Corda Server.

For more information about embedding Corda images, see Using Corda Embedder in the Corda 7 Developer Reference.