Home
Categories
Dictionnary
Download
Project Details
Changes Log
FAQ
License

Script context



A global context is available in all the scripts.

The context is available through the context field in your script. For example:

      public void clicked() {
         context.echo("Hello World");
      }

Context interface

The context have at least the following interface:

public class ScriptContext


Modifier and Type Method and Description
void abort(String message)
Abort the current script. The Scripting engine will use the throwable exception to stop the execution
void echo(String message)
Echo a message
void echo(Number number)
Echo a numeric value
void error(String message)
Error a message
XULScriptHelper getHelper()
Return the script helper
File getPath(String path)
Return the absolute path of a file defined relative to the script file
File getScriptFile()
Return the script file
ScriptLogger getScriptLogger()
Return the associated ScriptLogger

Note that abort(String message) will abort the script.

Using the context

The context is available as a context field in the script.

For example to show a message on the logger in a Groovy script:

      public void clicked() {
        context.echo("My value:" + value);
      }

Using a custom context


It is possible to use a custom XULScriptContext for all the scripts by ScriptManager.setScriptContext(XULScriptContext).

To define a custom XULScriptHelper, you should define a custom XULScriptContext and implement the XULScriptContext.getHelper() with your own XULScriptHelper implementation.

See also


Categories: scripts

Copyright 2008-2020 Herve Girod. All Rights Reserved. Documentation and source under the LGPL licence