Child pages
  • Specification (.spec file)

Versions Compared

Key

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

...

To define an array property just append "[]" to the type name.


Code Block
languagejs
"someTextProperties": "string[]"

To specify configuration options for each element of the array you can do:

...

For performance (and security) reasons, data modifications from client to server are not propagated by default. To enable this configure pushToServer setting on the property.


pushToServer valuedescription
rejectthis is the default, no data synchronization from client to server for this property
allowdata changes from client to server are allowed
shallowsame as allow, but sablo will also add a watch on the model (in the client) and send changes to the server; the watch is based on object reference/primitive value (more performant, but in case of structured/nested objects it will only trigger data synchronization when the objects are different by reference, even if they are actually 'equal' by content)
deep

same as allow, but sablo will also add a watch on the model (in the client) and send changes to the server; the watch is based on object equality (compares old and new values of structured/nested objects, less performant because it keeps and compares two copies of structured/nested objects); "deep" is mostly meant to be used for properties of type 'object' - that  can contain nested JSON - and that for any change (doesn't matter how little) will send over the complete value to the server.


 


Information about how "pushToServer" works in particular with Array property type and with Custom object property types can be found on the wiki pages of these property types.


 


For example:


Code Block
languagejs
titlepushToServer example
"model": {
   "searchfield": { "type": "string", "pushToServer": "shallow" }
} 


 


Note that in Servoy, data-provider property changes are sent to server using svy-apply (servoy api call) and svy-autoapply (directive); for these to work properly, these properties should set pushToServer to allow. Otherwise those data provider properties will be read-only.


Tags
Anchor
tags
tags


Properties can be configured with special tags that may be interpreted by the deployment and/or development environment.

...

Can be used to provide a caption for Custom Object Types in developer based on the value of a subproperty. For example if you create a table component that defines in .spec custom object types (that could also be "droppable" in developer) for columns, you might want to show as caption in developer for each such 'column' the header text subproperty value or - if that is not set - the dataprovider subproperty value. The captionPriority tag will allow you to specify in which order subproperties are checked for non-empty string values for the caption. That caption text ends up visible in places such as the outline view or in form designer for each column. You would specify it like this:


Code Block
languagejs
title(...).spec
    (...)
    "model": {
        "columns": { "type": "column[]", "droppable": true, (...) },
    (...)
     "types": {
        "column": {
            "dataprovider": { "type": "dataprovider",
                              "tags": { "useAsCaptionInDeveloper" : true,
                                        "captionPriority" : 2 }, (...) },
            "headerText": { "type": "tagstring",
                            "tags": { "useAsCaptionInDeveloper" : true,
                                      "captionPriority" : 1 }},
    (...)


 


showInOutlineView: boolean (for Servoy < 8.3)

...

A property can have a "default" value like:


Code Block
languagejs
"text": { "type": "string", "default": "I am a button" }


But this would mean that restore to default or empty the property would always set that default property back. This is wanted behavior if the property has to have some default value like if a property must be 1 of a few values and the default is one of those.

...

If a property should allow the developer to choose in the properties view from a predefined set of values you can use the "values" attribute in combination with default (default can be one of the predefined values but can also be something else):


Code Block
languagejs
"horizontalAlignment": {
    "type": "int",
    "tags": { "scope": "design" },
    "values": [
        { "LEFT": 2 },
        { "CENTER": 0 },
        { "RIGHT": 4 }
    ],
    "default": -1
}


 


But for a button or label in which you initially want some text, but reverting should really clear the text, the default value is not really usable (the label text should be able to be nothing, in case only an image is meant to be shown in that label). For this we have the attribute "initialValue":


Code Block
languagejs
 "text": { "type": "tagstring", "initialValue": "Button text", "tags": { "directEdit": "true" } }


This is like a constructor value, set only once when the component is added.

...

For example, the editable property as defined below will be true by default, when set to false changes from the client to the component will be rejected. Also functions cannot be called from the client.


Code Block
languagejs
titleExample editable
"model": {
   "editable" : { "type": "protected", "blockingOn": false, "default": true }
} 


 


Protection can be done for specific properties or functions.

...

removecustomer are protected.


Code Block
languagejs
titleExample protecting properties and handlers
"model:" {
    "customerAddress": "string", 
    "customerName": "string", 
    "protectCustomer": { "type": "protected", "for": ["removecustomer", "customerName"] }
   },
"handlers:" {
   "removecustomer": "function"
}


Protecting properties themselves can never be modified from the client.

...

In this example, a component's model can be filled with a customer name, but when the property visible is set to false, the component will be protected and the data will not be sent to the client. When visible is set to true, data not sent before will be pushed to the client.


Code Block
languagejs
titleExample visible
"model": {
   "visible": "visible",
   "customerName": "string"
} 


Visibility properties themselves can never be modified from the client.

...

Similarly to properties of type visible , the properties  of type enabled are also protecting properties, so they can never be modified from the client. 


Code Block
languagejs
titleExample enabled
"model": {
   "enabled": { "type": "enabled", "blockingOn": false, "default": true }
} 


It is important to use type enabled  if we want the value from the parent container (i.e. form, portal) to be pushed to the component. For instance if a portal is disabled, then all the components from the portal which have a property of type enabled will also be disabled.

...

If you want also a design time property to control the editable state then add a second property, see example below, and then having a tag in the template like: ng-readonly="model.readOnly || !model.editable"


 


Code Block
languagejs
titleListening to readonly
"model": {
  "readOnly": { "type": "protected", "blockingOn": true, "default": false, "tags": {"scope": "runtime"} },
  "editable": { "type": "protected", "blockingOn": false, "default": true }
}


 


With this property a component can do its thing to set or unset the readonly mode for itself.

...

Findmode is a special type: Findmode property type which can be used to set all kind of other properties which are normally protected from changing on the client side. Or you can just use it as a type for any property you want: 


Code Block
languagejs
titleListening to findmode
"model": {
  "myfindmodeproperty": "findmode"
}


 


When the find mode changes the boolean value of your property will also change. This way you can react to a form/foundset going into find mode. Like resetting a specific format, allowing any kind of input.

...