Child pages
  • Custom object property types

Versions Compared

Key

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

...

Info

"pushToServer" .spec setting of a custom object property is currently automatically inherited by the sub-properties of that property (so any "pushToServer" setting defined on sub-properties of the array will be ingnored). That means that for example if you define the custom object prop. to be "shallow" watched, all it's sub-properties will be shallow watched. If you don't define pushToServer or define "reject" then the sub-properties of that custom object will not be watched inside the browser and any changes to them will not be sent to the server.

You should not use pushToServer: "deep" on custom object property types, as that will actually add a deep watch on the custom object and any change within a sub-property of that custom object will be interpreted as an custom object prop. change and will send the full custom object value to the server. If you use "shallow" then the changes in custom object sub-properties are watched anyway (so in the end it is similar to a deep watch), so you normally do not need "deep" anyway; "deep" is meant more for properties of types like 'object' where you can have random JSON content that you want to be deep watched (so it sends it's whole value to the server for any change - so without granular updates).

Advanced .spec options

A configuration option (that you will most likely never need) for custom objects (available starting with Servoy 2019.09) is to be able to convert to null at runtime objects that have any of a set of specific keys set to null at design time ("setToNullAtRuntimeIfAnyOfTheseKeysAreNull": [ "a", "c" ]):

Code Block
languagejs
    "model":
    {
		"customObjConvertedToNullIfSpecificKeyIsNull": { "type" : "myCustomObj", "setToNullAtRuntimeIfAnyOfTheseKeysAreNull": [ "a", "c" ] }
		(...)
	},
    "types": {
        "myCustomObj": {
            "a": "string",
            "b": "int",
            "c": "string"
        }
    }

For example if in developer properties view you set on this property { "a": null, "b": 5, "c": "something"} then, at runtime, the property will be null because "a", one of the "setToNullAtRuntimeIfAnyOfTheseKeysAreNull" from .spec, is null. You will probably never need to use this option except for when you want to create advanced custom components that have arrays of columns that contain child components (so "model": { "columns": { "type" : "column[]", "skipNullItemsAtRuntime": true, "elementConfig": { "setToNullAtRuntimeIfAnyOfTheseKeysAreNull": [ "columnComponent" ] } }, "types": { "column": { "columnHeaderText": "string", "columnComponent": "component" } }) and where the security settings of a form might not allow some of the child components (columns) to be visible at runtime - depending on the user that logs in. In that case those items in the array would be set to null automatically by Servoy because the columnComponent is set to null automatically if it's not supposed to be visible - and most of the times in this case you want to just get browser-side the columns who's child components you can show in that array and not worry about nulls and not send anything related to that column to client. See also array type to understand what "elementConfig"above does.

Browser/client side value

...