Child pages
  • Server Side Scripting

Versions Compared

Key

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

...

Code Block
languagejs
title.spec file
"serverscript": "servoydefault/tabpanel/tabpanel_server.js",

Server side scripting should can contain API methods defined in the spec of the component / service.These methods execute then directly server-side. When a certain API is called from Servoy scripting, Servoy will first check if that API is defined server side. If it is, it will just call the server side API method.

If the API method is not defined in the server side file (or component doesn't have server side scripting at all) will send a message to client requesting an API call as defined by client js file. Any message sent to client will also send all outstanding model changes , Servoy will call that method from the client side js file of the service / component. Any such message or call that is send to client will send all the outstanding server-side model changes as well to the client - so that client will be in sync with server ( before the API is method gets called).

That file has that also As this server side file can also have the implementation of the api API that is defined in the .spec file, so you can handle complex things server side, ; this can be used as a performance enhancement so that the api call doesn't have to go to the client to execute at the moment the call comes is made from servoy Servoy solution code.

The api API call that is executed serverside server-side could for example just update some models model properties of the component/service, ; these will be then send sent automatically as one thing to the client when the servoy server-side code is done. Serverside And then client can detect those model changes. Or server-side code could call directly a client side API method after doing some pre-processing for example. More complex components like grouping girds based on foundsets or services like form popup service heavily rely on server-side implementation both for public APIs (defined in "api" section in the .spec file and present in server-side scripting through $scope.api.xyz()) and for private implementations details from internalAPIs (defined in "internalApi" section of the .spec file and present in server-side scripting through $scope.xyz()).

Server-side code is build up the same as the clientside client-side so you have $scope object with model, and api and (since 8.3) handler objects. On that $scope.api object you have to define then the public api methods that you want to execute server side. An example is the default tabpanelThe difference - compared to client side structure is that internalApis from .spec are defined directly on $scope compared to client - where internalApis are defined in the same place as public apis. More info on the $scope.handler object see belowusage is given below.

An example is the default tabpanel.

What can also be done (Servoy 8.0.2+) is that clientside scripting can call the server part. These function has to be defined on the $scope object, as an example:

...