INTERNAL operator
The INTERNAL operator creates an action or an action statement that executes an internal call.
Syntax
An INTERNAL operator may declare a standalone action:
INTERNAL [CLIENT] [syncType] className [(classId1, ..., classIdN)] [NULL]
INTERNAL [syncType] <{anyTokens}> [NULL]
or be used inline as an action statement:
INTERNAL internalCall [PARAMS paramExpr1, ..., paramExprN] [TO propertyId1, ..., propertyIdM]
internalCall — an internal-call target defined by one of the following syntaxes:
DB execStrExpr
CLIENT [syncType] execStrExpr
Description
The INTERNAL operator creates an action or an action statement that runs either Java code in the application-server JVM, a resource in the user's web client, or SQL against the platform's own database — collectively an internal call. The inline statement form is used when the call target (resource name or SQL command) has to be computed at call time.
Parameters
-
CLIENTKeyword. Targets the user's web client instead of the application-server JVM — a JavaScript function already loaded in the client, or a client-side file (resolution rule on
execStrExpr/classNamebelow). WithoutCLIENTthe call targets the JVM (a Java class extendingInternalAction, or an inline Java snippet). In the inline statement formCLIENTandDBare mutually exclusive and one of them is required. -
syncTypeKeyword. One of:
WAIT— synchronous.NOWAIT— asynchronous.
Only has an effect on
CLIENTcalls. WithoutsyncTypethe call is asynchronous; in the inline statement form a non-emptyTOadditionally forces synchronous execution. For non-CLIENTstandalone calls the keyword is accepted by the grammar but ignored. -
classNameString literal. Without
CLIENT— fully qualified name of a Java class reachable from the application-server classpath; the class must extendlsfusion.server.physics.dev.integration.internal.to.InternalAction. WithCLIENT— name of a client-side resource (resolution rule identical toexecStrExprbelow). -
classId1, ..., classIdNList of class IDs of the created action's parameters. An empty list (
()) means the action takes no parameters. Without the list at all, the parameter classes are taken from the surrounding action declaration's typed parameters. Only applies to theclassNameform. -
NULLKeyword allowing
NULLvalues to be passed as parameters of the created action. WithoutNULLany call that passesNULLis skipped silently and control passes to the next statement. Silently ignored whenCLIENTis specified. -
anyTokensSource code written in Java. Used as the body of the
executeInternalmethod on a class generated by the platform. The only in-scope variable iscontextof typelsfusion.server.logics.action.controller.context.ExecutionContext<ClassPropertyInterface>. The fragment body is additionally wrapped intry { ... } catch (Exception e) { e.printStackTrace(); }: any exception thrown from the fragment is caught, printed to the application server's stderr, and does not abort the action. To let exceptions propagate normally, use theclassNameform. -
DBKeyword. Runs SQL against the platform's own database. Semantics match
EXTERNAL SQL—$Nparameter substitution,TABLEparameters uploaded as temporary tables, an.sqlexpression treated as a classpath resource, and DML/SELECTresults written toTOproperties — except that no connection string is supplied and the call is performed inside the current change session. Mutually exclusive withCLIENT. -
execStrExprExpression.
DB: the SQL command.CLIENT: the resource name — a plain identifier ([a-zA-Z0-9_$]+) is resolved as a JavaScript function defined in the client-loaded code; any other value is treated as a client-side file reference and either looked up in theweb/classpath or, if not found there, passed through the application server's file/URL conversion, which also accepts absolute URLs. Scripts, stylesheets and fonts (.js,.css,.ttf,.otf) are recognised by file extension and handled specially on the client; all other file types, including images, are delivered to the client as generic files. A value prefixed withremoveunloads the previously-loaded file of the corresponding kind instead of invoking it; this prefix only affects the file branch — with a JavaScript-function target it is silently ignored. File resources do not receive parameters. -
paramExpr1, ..., paramExprNList of expressions passed as call parameters (
$Nsubstitutions forDB; positional arguments forCLIENT). WithoutPARAMSthe call has no parameters. -
propertyId1, ..., propertyIdMList of property IDs (without parameters) into which results are written. For
DB, results are written in the order of the corresponding queries; forCLIENT, at most one property is accepted and supplying it also forces synchronous execution. WithoutTOno result is captured.
Examples
// Java class with explicit parameter classes
showOnMap 'Show on map'
INTERNAL 'lsfusion.server.logics.classes.data.utils.geo.ShowOnMapAction' (DOUBLE, DOUBLE, MapProvider, BPSTRING[100]);
// Java class accepting NULLs
serviceDBMT 'DB maintenance (multithreaded, threadCount, timeout)'
INTERNAL 'lsfusion.server.physics.admin.service.action.ServiceDBMultiThreadAction' (INTEGER, INTEGER) NULL;
// inline Java snippet — prints to the application-server console
printlnAction 'Print text to the console' INTERNAL <{ System.out.println("action test"); }>;
// client-side JS function declared as an action, with parameter classes
QZPrint INTERNAL CLIENT 'QZPrint' (JSON, JSON, JSON);
// client-side JS function declared as an action, without parameters
reload INTERNAL CLIENT 'reload';
// inline client call — resource reference is an absolute URL, loaded synchronously
loadMarkdownLibrary() {
INTERNAL CLIENT WAIT r'https://cdn.jsdelivr.net/npm/marked/marked.min.js';
}
// inline client call — JS function with PARAMS and a single result captured via TO
getCookie(STRING name) {
LOCAL cookie = STRING();
INTERNAL CLIENT 'getCookie' PARAMS name TO cookie;
}
// inline SQL — command taken from a property expression and evaluated at call time
runScript(STRING script) {
INTERNAL DB script;
}
// inline SQL — parameterized query, result written to a TABLE file via TO
loadPrices() {
EXPORT TABLE FROM bc=barcode(Article a) WHERE name(a) LIKE '%Meat%';
INTERNAL DB 'select price, barcode from $1' PARAMS exportFile() TO exportFile;
}