Versions Compared

Key

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

...

The servoyApi is a Servoy specific api which can be used by web components for interacting to interact with the server. It must be declared in the private scope of the component.

 

Code Block
languagejs
titlecomponent.js
angular.module('mypackageComponent',['servoy']).directive('mypackageComponent', function() {  
    return {
      restrict: 'E',
      scope: {
    	  model: "=svyModel",
          svyServoyapi: "="
      },

 

The servoyApi provides the following methods:

...

Method

Parameters

Description

apply

propertyName the name of the property of type dataprovider

Pushes a changed dataprovider value of the component to the server.

It is used by the svy-autoapply directive, but it can also be used directly by the webcomponent.

For example the radio button pushes the new value to the server when the radio is clicked:

Code Block
languagejs
titleradio.js
$scope.radioClicked = function()
{
	$scope.model.dataProviderID = $scope.model.valuelistID[0].realValue;
	$scope.svyServoyapi.apply('dataProviderID')
}

callServerSideApi

methodName the name of the serverside method to call

args the arguments of the serverside method

Used on the client side to call a function which is defined in the server side api of the component .

 

formWillShow

formname – the name of the form which will be shown

relationname – the name of the relation (optional)

formIndex – the formIndex in the tabpanel (optional)

Prepare the form for showing. Usage example tabpanel component when switching tabs:

Code Block
languagejs
titletabpanel.js
function setFormVisible(tab,event) 
{
	if (tab.containsFormId) $scope.svyServoyapi.formWillShow(tab.containsFormId,
tab.relationName);

 

 

hideForm

formname – the name of the form to hide

relationname the name of the relation (optional)

formIndex the formIndex in the tabpanel (optional)

Hides the form.

Used by the tabpanel to hide the previously selected tab.

getFormUrl

formName

Return the URL of a form. Example tabpanelIt can be used together with ng-include to include a form in the component template:

Code Block
languagejsxml
titletabpanelcomponent.jshtml
$scope.getForm = function(tab) 
{
  if ($scope.model.selectedTab && tab.containsFormId == $scope.model.selectedTab.containsFormId) 
 {
   return $scope.<div ng-include="svyServoyapi.getFormUrl(tab.containsFormId);
 }
  return "";
}myFormName)" ></div>

 

 

 

 

startEdit

propertyName the name of the property which is edited

Signal that the editing of a property has started, usually at focus gained.