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.
Javascript

...

Scope

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

...

Code Block
forms.customers.controller.newRecord();  // invokes a form object from another scope

compared to:

Code Block
function createNewCustomer(){  // a method defined within the 'customers' form scope

    controller.newRecord();    // invokes the same form object from within the form's scope. Notice the fully qualified namespace is notNOT required

}
Creating a Variable

To create a global variable:

  1. From the Solution Explorer tree, expand the Active Solution and the Globals node. Right-click the variables node and select Create Variable from the pop-up menu. Choose a variable name, a data type and optionally choose an initial value and click OK.
  2. From the Solution Explorer tree, expand the Active Solution and the Globals node. Highlight the variables node and click the Create Variable button from the lower toolbar in the Solution Explorer. Choose a variable name, a data type and optionally choose an initial value and click OK.
Creating a Method
Implementing Basic Business Logic