File Downloads

An ACTION_CONTROL with the TYPE set to FILE_DOWNLOAD results in the generation of a hyperlink on the page. Clicking on the hyperlink invokes a special FileDownload servlet included in the Cúram CDEJ that returns the contents of a file from the database. The FileDownload servlet is configured with the server interface to call to get the file contents and the parameters to pass to identify that file. The configuration is performed in the curam-config.xml file. A single server interface can be configured for each page of the application that includes file download action controls. An example configuration is shown in File Downloads, below:

A WIDGET with the TYPE set to FILE_DOWNLOAD can also be used to generate a hyperlink to download a file. You should use the ACTION_CONTROL element when the hyperlink text is the fixed LABEL value. The FILE_DOWNLOAD WIDGET allows the hyperlink text to be a dynamic value retrieved from a server interface property.

Figure 1. Example Configuration for File Download
<APP_CONFIG>
  <FILE_DOWNLOAD_CONFIG>
    <FILE_DOWNLOAD PAGE_ID="FileDownload"
        CLASS="curam.interfaces.FilePkg.File_read_TH">
      <INPUT PAGE_PARAM="fileID" PROPERTY="key$fileID"/>
      <FILE_NAME PROPERTY="dtls$fileName"/>
      <FILE_DATA PROPERTY="dtls$fileData"/>
    </FILE_DOWNLOAD>
  </FILE_DOWNLOAD_CONFIG>
</APP_CONFIG>

Each configuration for downloading files is contained in a FILE_DOWNLOAD element within the FILE_DOWNLOAD_CONFIG element in the configuration file. There should be one FILE_DOWNLOAD element for each page that contains file download action controls.

The FILE_DOWNLOAD element takes two attributes: PAGE_ID for the identifier of the page containing the action controls to which this configuration will be applied, and CLASS containing the name of the server interface that will be called by the FileDownload servlet when the generated hyperlink is invoked.

The FILE_DOWNLOAD element can contain zero or more INPUT elements specifying the key values to set before the server interface is called. These INPUT elements associate page parameters with properties of the server interface. The PAGE_PARAM attribute specifies the name of the page parameter whose value will be used as a key value, and the PROPERTY attribute specifies the key property of the server interface that must be set to identify the file. The page parameters are set by the LINK element within the ACTION_CONTROL, as you will see below.

The other three elements, FILE_NAME and FILE_DATA, and CONTENT_TYPE all have PROPERTY attributes that indicate the properties of the server interface that will contain the name of the file, the contents of the file, and the content type of the file respectively, after the server interface is called. This data is returned to the client in response to the activation of the hyperlink and the user's browser will present them with the download dialog box prompting them to save or open the file.

Where property names are specified, the names must be written in full and cannot be abbreviated like they can in UIM documents.