Home
Categories
Dictionnary
Download
Project Details
Changes Log
FAQ
License

Using a custom ScriptContext



It is possible to use a custom ScriptContext for all the scripts, or only for one ScriptLanguageFactory

Define the custom context and helper

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

Note that:

Apply the context

If you want to set the ScriptContext for all scripts, you have to set it to the ScriptManager, by ScriptManager.setScriptContext(XULScriptContext).

If you want to set it only for one ScriptLanguageFactory, you have to return your custom context by the ScriptLanguageFactory.getScriptContext() method.

Example


The custom context tutorial presents how to add a new getLength(File file) method for the ScriptHelper, and apply it to all scripts.

See also


Categories: scripts

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