Child pages
  • Implementing Business Logic

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Note
titleNote

Developers who are familiar with Javascript may cite issues with browser support and speed of execution.

However, it is worth noting that Servoy does not deploy any Javascript. All code written in Servoy is deployed using Mozilla's Rhino project, which is an open-source, Java-based Javascript implementation.

This means that:

  1. All methods are executing in Java (orders of magnitude faster than interpreted Javascript)
  2. No business logic is ever exposed or executed in the browser, thereby eliminating browser support issues.
  3. Experienced developers can optionally use 3rd-party java APIs, mixing Java code directly in their Servoy methods.
'Scope' in Javascript

...


Scope defines the domain in which code is executed and subsequently determines the namespace by which scripted objects are referenced. Javascript code (functions and variables) may be defined in the following two scopes:

Global Scope: Accessible Found in the globals.js file and accessible via the namespace globals, i.e.

Code Block
globals.createNewCustomer(); // invokes the global method

Form Scope: Accessible Found in the formName.js file and accessible via the namespace forms.formName, i.e.

...

  • From the Solution Explorer tree, navigate to and highlight a node for a scriptable resource. In the list of methods and properties provided in the lower part of the Solution Explorer, highlight the method or property that you wish to invoke and click the Move Sample button in the lower toolbar of the Solution Explorer. A verbose, commented sample will be copied into the Script Editor.

...

Using Code-Complete in the Script Editor

...

Tip
titleTip

Any scripting API (including methods written by a developer) can be auto-completed using key strokes.

To use auto-complete, begin typing the code you wish to execute, then hit ctrl+space on the keyboard. A type-ahead list of available scripting objects will appear for you to choose from as you type. This is a highly productive and accurate way to write code when you have become more familiar with the APIs.

Tip
titleTip

If you are unfamiliar with Javascript syntax, that's OK. In the Solution Explorer, navigate to the JS Lib node. This object contains a list of APIs for dealing with the Javascript language and native data types. It even contains syntax completion for common statements in the Statements node.