RoundTrip events

List of the events in the RoundTrip JavaScript API.

taskStart (event ID: 78)

The taskStart event is fired whenever a RoundTrip process is started. This invokes the method specified in the eventHandler parameter. If you listen for this event, you must respond, by using the callback response method.

For example, if your handler is called eventHandler, it would have the following signature:
eventHandler(78, taskId, callbackId, editModeSpecificParam)
Table 1. Handler signature parameters
Parameter Description
78 The ID of the event.
taskId The taskId of the current RoundTrip task.
callbackId The callback ID to be passed in to the setEventHandlerCallbackResponse call for this handler.
editModeSpecificParam This parameter is present in Document Builder mode only and corresponds to the current configuration.

In redaction mode this parameter is not present.

This event is a JSON string with the following attributes:
Attributes Description
actions An array of JSON maps that indicate the actions to be performed in this document build. This is commonly referred to as a recipe. See the following code example.
allow A Boolean that indicates whether the task corresponding to this taskStartEvent must be allowed or canceled.
showProgress A Boolean that indicates whether the progress dialog must be shown.
config A JSON map that contains the mimeType attribute.
mimeType A string that indicates the mime type of the Document Builder output document. Valid values are:
  • application/pdf

Example

The following code sample shows an example of the JSON configuration:

{ 
  "actions": 
  [   
    { 
      "source": 
      { 
        "location":"http://localhost/input/pdf/agreement.pdf", 
        "versionInfo":"0",  
        "annotationHash":"md5" 
      }, 
      "viewId":"Document BuilderControllerViewID", 
      "type":"LoadDocument" 
    }, 
    { 
      "source": 
      { 
        "location":"http://localhost/input/pdf/p1.pdf", 
        "versionInfo":"0", 
        "annotationHash":"md5" 
      }, 
      "viewId":"DocumentDataSource=[http://localhost/input/pdf/p1.pdf]", 
      "type":"LoadDocument" 
    }, 
    { 
      "fromView":"DocumentDataSource=[http://localhost/input/pdf/p1.pdf]", 
      "fromFirstPage":1, 
      "fromLastPage":1, 
      "toView":"Document BuilderControllerViewID", 
      "toPage":2, 
      "type":"CopyPages" 
    }, 
    { 
      "page":1, 
      "annotations":"[EMPTY]", 
      "viewId":"Document BuilderControllerViewID", 
      "type":"ReplaceAnnotations" 
    } 
  ], 
  "allow":true, 
  "showProgress":true, 
  "config": 
  { 
    "mimeType":"application/pdf" 
  } 
} 
The callback response that is required for this event has the following signature:
setEventHandlerCallbackResponse(callbackId, editModeSpecificParam)
Table 2. Callback signature parameters
Parameter Description
callbackId The callbackId passed to the eventHandler.
editModeSpecificParam
  • Redaction mode
    In Redaction mode, this parameter is a string status, which can have the following values:
    • ok: The task can continue.
    • cancel: The task must be canceled.
  • Document Builder mode

    In Document Builder mode, this parameter is a JSON string. This JSON can be equal to the JSON configuration passed in to the eventHandler. In this case, the build is allowed to continue, the output mimeType of the build is set to PDF, and the progress bar is shown.

    Alternatively, the JSON configuration might be parsed, by using JSON.parse for example, and the values of the attributes can be changed to alter the behavior of the build. For example, the allow attribute might have a value of false and this would cancel the build. The mimeType attribute might be set to application/pdf to set the output mime type of the document build to PDF. The showProgress attribute might be set to false to prevent the display of the progress dialog.
    Note: allow is the only required attribute. Changes to the actions inside the JSON configuration do not affect the Document Builder task.

taskStarted (event ID: 79)

The taskStarted event is fired after the callback for taskStart was called. This event signals that the RoundTrip task is in progress.

For example, if your handler is called eventHandler, it would have the following signature:
eventHandler(79, taskId, callbackId)
Table 3. Handler signature parameters
Parameter Description
taskId The taskId of the current RoundTrip task.
callbackId The callback for this event can be used to cancel the document build.

The callback response that is required for this event has the following signature:

setEventHandlerCallbackResponse(callbackId, status)
Table 4. Callback signature parameters
Parameter Description
callbackId The callbackId passed to the eventHandler.
status A string equal to one of the following values:
  • ok: Continue the corresponding doc builder task.
  • cancel: Cancel the corresponding doc builder task.

taskStatus (event ID: 80)

The taskStatus event is fired after the taskStarted event is called. This event can be fired multiple times and is triggered when IBM Daeja ViewONE receives progress from the server.

For example, if your handler is called eventHandler, it would have the following signature:

eventHandler(80, taskId, status, editModeSpecificParam)
Table 5. Handler signature parameters
Parameter Description
taskId The taskId of the current RoundTrip task.
status A string that represents the current status of the task. The values can be as follows:
  • ok: The RoundTrip task completed.
  • cancel: The RoundTrip task was canceled.
  • error: The RoundTrip task failed with an error.
  • usercancel: The RoundTrip task was canceled by a user.
editModeSpecificParam
  • Redaction mode
    In Redaction mode, this is a JSON representation of the output of the redaction. The JSON is composed of a set of attributes, which are as follows:
    • url: An array of urls
    • mimeType: An array of mime types
    For example:
    { 
    "url": 
    [ 
    "http://DUMMYURL" 
    ], 
    "mimeType":  
    " application/pdf" 
    ] 
    } 
    
  • Document Builder mode
    In Document Builder mode, this is a JSON value that stores the output of the document build. The JSON is composed of an array of JSON maps, each of which represents one of the results of the build, and has the following attributes:
    • type: The output type of the result
    • url: The url of the result
    • name: The name of the result
    • mimeType: The mime type of the result
    For example:
    [ 
    { 
    "type":"annotations", 
    "url":"http://DUMMYURL", 
    "name":"v1.ant", 
    "mimeType":"text/vnd.ibm.viewone-annotations+ant" 
    }, 
    { 
    "type":"document", 
    "url":"http://DUMMYURL", 
    "name":"MyDocument.pdf", 
    "mimeType":"application/pdf" 
    } 
    ]
    

The callback response that is required for this event has the following signature:

setEventHandlerCallbackResponse(callbackId, editModeSpecificParam)