Child pages
  • Specification (.spec file)

Versions Compared

Key

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

...

Code Block
languagejs
titletabpanel.spec
{
    "name": "servoydefault-tabpanel",
    "displayName": "Tab Panel",
    "version": 1,
    "icon": "servoydefault/tabpanel/tabs.gif",
    "definition": "servoydefault/tabpanel/tabpanel.js",
    "serverscript": "servoydefault/tabpanel/tabpanel_server.js",
    "libraries": [{"name":"accordionpanel", "version":"1", "url":"servoydefault/tabpanel/accordionpanel.css", "mimetype":"text/css"}],
    "model":
    {
            "background" : "color", 
            "borderType" : {"type":"border","stringformat":true}, 
            "enabled" : { "type": "enabled", "blockingOn": false, "default": true }, 
            "fontType" : {"type":"font","stringformat":true}, 
            "foreground" : "color", 
            "horizontalAlignment" : {"type" :"int", "tags": { "scope" :"design" }, "values" :[{"LEFT":2}, {"CENTER":0},{"RIGHT":4}],"default" : -1}, 
            "location" : "point", 
            "readOnly" : "protected", 
            "selectedTabColor" : "color", 
            "size" : {"type" :"dimension",  "default" : {"width":300, "height":300}}, 
            "styleClass" : { "type" :"styleclass", "tags": { "scope" :"design" }, "values" :[]}, 
            "tabIndex" : { "type": "object", "pushToserver": "shallow" }, 
            "tabOrientation" : {"type" :"int", "tags": { "scope" :"design" }, "values" :[{"default" :0}, {"TOP":1}, {"HIDE":-1}]}, 
            "tabSeq" : {"type" :"tabseq", "tags": { "scope" :"design" }}, 
            "tabs" : {"type":"tab[]", "droppable":true}, 
            "transparent" : "boolean", 
            "visible" : "visible" 
    },
    "handlers":
    {
            "onChangeMethodID" : "function", 
            "onTabChangeMethodID" : "function" 
    },
    "api":
    {
            "addTab": {
                "returns": "boolean",
                "parameters":[
                                {                                                                 
                                 "name":"form/formname",
                                "type":"object []"
                                },
                                 {                                                                 
                                 "name":"name",
                                "type":"object",
                                "optional":true
                                },
                                 {                                                                 
                                 "name":"tabText",
                                "type":"object",
                                "optional":true
                                },
                                 {                                                                 
                                 "name":"tooltip",
                                "type":"object",
                                "optional":true
                                },
                                 {                                                                 
                                 "name":"iconURL",
                                "type":"object",
                                "optional":true
                                },
                                 {                                                                 
                                 "name":"fg",
                                "type":"object",
                                "optional":true
                                },
                                 {                                                                 
                                 "name":"bg",
                                "type":"object",
                                "optional":true
                                },
                                 {                                                                 
                                 "name":"relatedfoundset/relationname",
                                "type":"object",
                                "optional":true
                                },
                                 {                                                                 
                                 "name":"index",
                                "type":"object",
                                "optional":true
                                }             
                             ]
            },
            "getMaxTabIndex": {
                "returns": "int"
            },
            "getMnemonicAt": {
                "returns": "string",
                "parameters":[
                                {                                                                 
                                 "name":"i",
                                "type":"int"
                                }             
                             ]
            },
            "getSelectedTabFormName": {
                "returns": "string"
            },
            "getTabBGColorAt": {
                "returns": "string",
                "parameters":[
                                {                                                                 
                                 "name":"unnamed_0",
                                "type":"int"
                                }             
                             ]
            },
            "getTabFGColorAt": {
                "returns": "string",
                "parameters":[
                                {                                                                 
                                 "name":"i",
                                "type":"int"
                                }             
                             ]
            },
            "getTabFormNameAt": {
                "returns": "string",
                "parameters":[
                                {                                                                 
                                 "name":"i",
                                "type":"int"
                                }             
                             ]
            },
            "getTabNameAt": {
                "returns": "string",
                "parameters":[
                                {                                                                 
                                 "name":"i",
                                "type":"int"
                                }             
                             ]
            },
            "getTabRelationNameAt": {
                "returns": "string",
                "parameters":[
                                {                                                                 
                                 "name":"i",
                                "type":"int"
                                }             
                             ]
            },
            "getTabTextAt": {
                "returns": "string",
                "parameters":[
                                {                                                                 
                                 "name":"i",
                                "type":"int"
                                }             
                             ]
            },
            "isTabEnabled": {
                "returns": "boolean",
                "parameters":[
                                {                                                                 
                                 "name":"unnamed_0",
                                "type":"int"
                                }             
                             ]
            },
            "isTabEnabledAt": {
                "returns": "boolean",
                "parameters":[
                                {                                                                 
                                 "name":"i",
                                "type":"int"
                                }             
                             ]
            },
            "removeAllTabs": {
                "returns": "boolean"
            },
            "removeTabAt": {
                "returns": "boolean",
                "parameters":[
                                {                                                                 
                                 "name":"index",
                                "type":"int"
                                }             
                             ]
            },
            "setMnemonicAt": {
                "parameters":[
                                {                                                                 
                                 "name":"index",
                                "type":"int"
                                },
                                 {                                                                 
                                 "name":"text",
                                "type":"string"
                                }             
                             ]
            },
            "setTabBGColorAt": {
                "parameters":[
                                {                                                                 
                                 "name":"unnamed_0",
                                "type":"int"
                                },
                                 {                                                                 
                                 "name":"unnamed_1",
                                "type":"string"
                                }             
                             ]
            },
            "setTabEnabled": {
                "parameters":[
                                {                                                                 
                                 "name":"unnamed_0",
                                "type":"int"
                                },
                                 {                                                                 
                                 "name":"unnamed_1",
                                "type":"boolean"
                                }             
                             ]
            },
            "setTabEnabledAt": {
                "parameters":[
                                {                                                                 
                                 "name":"i",
                                "type":"int"
                                },
                                 {                                                                 
                                 "name":"b",
                                "type":"boolean"
                                }             
                             ]
            },
            "setTabFGColorAt": {
                "parameters":[
                                {                                                                 
                                 "name":"i",
                                "type":"int"
                                },
                                 {                                                                 
                                 "name":"s",
                                "type":"string"
                                }             
                             ]
            },
            "setTabTextAt": {
                "parameters":[
                                {                                                                 
                                 "name":"index",
                                "type":"int"
                                },
                                 {                                                                 
                                 "name":"text",
                                "type":"string"
                                }             
                             ]
            }
    },
"types": {
  "tab": {
          "name": "string",
          "containsFormId": "form",
          "text": "tagstring",
          "relationName": "relation",
          "active": "boolean",
          "foreground": "color",
          "disabled": "boolean",
          "imageMediaID": "media",
          "mnemonic": "string"
      }
}
     
}

 

Serverside scripting

A component or service can have a serverside part, so logic is executed on the server, in the spec file this is configured like:

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

 

That file has that also the implementation of the 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 from servoy code.

The api call that is executed serverside could for example just update some models of the component/service, these will be then send as one thing when the servoy code is done.

Serverside code is build up the same as the clientside so you have $scope object with model and api objects. On that api object you have to define then the api methods that you want to execute server side. 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:

 

Code Block
languagejs
titleserverside script
$scope.mycallback = function(name,type) {
	return "something";
}

 

then a component can use the servoyapi to call this

Code Block
languagejs
titleclient javascript
  // assign to the scope the svy-servoyapi
  scope: {
    	  model: '=svyModel',
		  servoyApi: '=svyServoyapi'
      },
 
// in the controller or link functions you can use that then
 $scope.servoyApi.callServerSideApi("mycallback",["string",1]).then(function(retValue) {
   console.log(retValue);    
 });

 

the callServerSideApi wants to have the function name and an array of arguments, it returns a promise of angular where the then function will give you the return value of the callback.

For a service you can use the $services service to do the same thing. the only thing extra is that you have to also give the servicename itself:

Code Block
languagejs
titleclientside service script
$services.callServerSideApi("myservicename","mycallback",["string",1]).then(function(retValue) {
   console.log(retValue);    
 });