There are three types of custom actions you can define:
Custom JavaScript actions. These actions will call a JavaScript function when they are fired.
Custom URL actions. These actions will open a URL when they are fired.
Custom Java actions. These actions will execute a Java class when they are fired., allowing you to execute custom Java classes.
A custom JavaScript action calls a JavaScript function when fired. The JavaScript function must be defined in the page loading the editor. For example if we wanted the editor to have a toolbar button inserting the current date, we'd first implement a JavaScript function inserting the current date into the editor when called, then we'd define an action calling this function when it is fired and finally we'd add a button to the toolbar associated with this custom action. Moreover, when the JavaScript function called by the action is fired, it will receive a reference to the applet as first argument, which can then be used to communicate with the applet.
Example II.1. The insertDate function
function insertDate(applet) {
now = new Date();
month = now.getMonth();
month++;
applet.insertHTMLData(now.getYear()+"-"+month+"-"+now.getDate());
applet.pumpEvents();
}Example II.2. Defining the custom JavaScript action INSERTDATE
<actions>
<actionjs id="INSERTDATE"
jsfunction="insertDate"
icon="icons/date.gif">
<shortcut id="alt D"></shortcut>
</actionjs>
</actions>Example II.3. Defining a toolbar button calling the custom action INSERTDATE
<toolbar>
<button localeid="Insert Date" actionid="INSERTDATE"/>
</toolbar>A custom URL action will open a URL when fired. The target frame in which the URL will be opened can be specified optionally.
Example II.4. Defining a custom URL action
<actions>
<actionurl id="ROWEBSITE"
icon="icons/url.gif"
url="http://wwww.realobjects.com"
target="_new" />
</actions>
A custom Java action will call a custom Java class when fired. The class must be available within the editor's classpath. You can ensure this by placing the class in a Java Archive (.jar) and loading this archive using the JavaScript API method setArchive . For details, see the chapter JavaScript API .
Example II.5. Defining a custom Java action
<action id="TEMPLATEPICKER"
class="com.realobjects.customdialogs.templatepicker.TemplatePicker"
icon="icons/templatepicker.gif" />