the type (module or script) has nothing to do with the location where the code is executed. Both script and module code can be executed in the client or on the server. It only depends on the context - i.e. how and where the start is triggered. Despite modules are always installed on the server, the client can load them from there and execute the code locally.
In general, we strongly recommend modules instead of beanshell scripts for multiple reasons:
- Scripts can only manually be checked for changed API as they are evaluated at runtime. If e.g. at some time a class or method is removed from the API, you only get aware of this when the script runs AND the concrete line of code is really executed.
- Modules: Full IDE support with code completion, syntax checks, auto imports, unit tests, refactoring etc.
- Management of code using VCS
- The risk of typos is very high in scripts, there is no check for misspelled variables, methods, classes or forgotten parameters or wrong types. Errors will only occur (and get visible) when the line is executed.
- You cannot create re-usable elements
- Only very basic support of java generics
- Slower execution
Technically you don't "execute a module" but more precisely one of the module's components. One common component type is a class implementing the Executable interface and declared as <public> component. Such Executables can then be used in FS_BUTTONs. The Executable interface defines an "execute" method you will have to implement. Here, you get a parameter map of type Map<String, Object>. You can acces the context object using the key "context" from that Map.
In some cases (e.g. workflow scripts, (context) menu scripts) you need a "script object". But this can directly delegate to an Executable in a module. Such a script contains only two lines:
For more information, you should have a look at the plugin development topics in the ODFS and especialy the examples.