Skip Navigation

Registering JavaScript Functions as Services

To register a JavaScript function as a service, you must wrap your web application as a Red App plug-in using a default implementation. For information, see About Website Integration Using Default Implementations.

Pre-defined Handler Classes

You are required to use the pre-defined handler classes below.

  • Web app in an editor:

  • Web app in a view:

Registering Your Service

  1. Add a dependency to the plug-in to manifest file.

  2. Add a Service entry to the CFBundle entity within your redapp.xml file, as shown below.

<Service name="EMU_COMMAND" action_code="HOT"
status="" desc="">
<ExternalHandler target="" force_focus=ťfalseť/>

This sample registers the EMU_COMMAND service with the HOT command prefix for the action code. The handler represents a web app that is wrapped as a view.

For details about registering JavaScript functions as services in redapp.xml, see Registering a JavaScript Function as a Service in "Building a redapp.xml File."

To send Sabre system special characters as action codes, map the characters in action_code in redapp.xml. Encode redapp.xml as UTF-8. For more information, see Sabre System Special Characters.

Obtaining and Modifying a Service Context

  1. In your JavaScript script, obtain and modify the service context that the SRWRuntime bus sends. The function argument is the context in JSON format. To return the modified context from your script, call the function that you defined in your redapp.xml file with the context as a string. The bus will wait until this function is called.