Child pages
  • Custom object property types
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Next »

Purpose of custom (object) property types

The custom object property type can be used by web components to logically group a number of subproperties (that can be of different types) for easier usage.

Such custom object types are able to send granular updates between server and client. For example if you change from Rhino one subproperty value (or for more complex element property types - such as 'component' type - if something changes in only one of the subproperties) then only the change is sent over to the browser/client instead of the whole custom object (and the other way around - a subproperty change on client doesn't send the full object, just the change to server).

Custom object types are defined in .spec files with a fixed set of subproperties as below:

.spec file

    "model": {
        (...)
        "myPerson": "person"
		(...)
    },
    (...)
    "types": {
        "person": {
          "firstName": "string",
          "lastName": "string",
          "photo": "dataprovider"
          "styleClass" : { "type": "styleclass",
                           "tags": { "scope" :"design" },
                           "values": ["form-control", "input-sm", "svy-padding-xs"] }
        }
    }

Browser/client side value

The browser value of such a property is a Javascript object containing the defined sub-properties:

    {
        "firstName": "John",
        "lastName": "Doe",
        "photo": "https://...."
    }

Server side javascript value

The server side JS value of such a property is a custom implementation based on Javascript object - so you should be able to use it just like a normal JS object.

Developer handling of custom object properties

Custom object properties can be edited at design-time from Servoy Developer's properties view and/or using drag and drop operations depending on type and configuration options. (TODO add more details here)

Nesting with custom object and array types

Custom object types can be nested with array types. This allows you to organize your model's properties better. For example (in .spec file):

    "model": {
        (...)
        "persons": { "type": "person[]" }
		(...)
    },
    (...)
    "types": {
        "person": {
          "firstName": "string",
          "lastName": "form",
          "profilePhotos": "dataprovider[]"
        }
    }

So the 'persons' property at runtime (client side) could look like this:

[
    { "firstName": "John", lastName: "Doe",
      "profilePhotos": [ "https://....", "https://...." ] },
    { "firstName": "Bob", lastName: "Smith",
      "profilePhotos": [ "https://....", "https://...." ] },
    { "firstName": "Jane", lastName: "Doe",
      "profilePhotos": [ "https://....", "https://...." ] },
]
  • No labels