classReadOnlyChildModelSync
Source: read-only-child-model-sync.
Represents the definition of a synchronous read-only child model.
Property
Methods
new ReadOnlyChildModelSync(parent[, eventHandlers])
Creates a new synchronous read-only child model instance.
The name of the model type available as: <instance>.constructor.modelType, returns 'ReadOnlyChildModelSync'.
Valid parent model types are:
* ReadOnlyRootCollectionSync
* ReadOnlyChildCollectionSync
* ReadOnlyRootModelSync
* ReadOnlyChildModelSync
* CommandObjectSync
Parameters
Name | Type | Optional | Description |
---|---|---|---|
parent |
object |
|
The parent business object. |
eventHandlers |
Yes |
The event handlers of the instance. |
- Extends
- ModelBase
- Fires
- ReadOnlyChildModelSync#event:preFetch
- ReadOnlyChildModelSync#event:postFetch
- Throws
-
Argument error: The parent object must be a ReadOnlyRootCollectionSync, ReadOnlyChildCollectionSync, ReadOnlyRootModelSync, ReadOnlyChildModelSync or CommandObjectSync instance.
-
Argument error: The event handlers must be an EventHandlerList object or null.
Property
read-only$modelName
string
The name of the model. However, it can be hidden by a model property with the same name.
Methods
protected staticcreate(parent[, eventHandlers]) → ReadOnlyChildModelSync
Creates a new read-only business object instance.
This method is called by the parent object.
Parameters
Name | Type | Optional | Description |
---|---|---|---|
parent |
object |
|
The parent business object. |
eventHandlers |
Yes |
The event handlers of the instance. |
- Returns
-
ReadOnlyChildModelSync
A new read-only business object.
protected staticload(parent, data[, eventHandlers]) → ReadOnlyChildModelSync
Initializes a read-only business object width data retrieved from the repository.
This method is called by the parent object.
Parameters
Name | Type | Optional | Description |
---|---|---|---|
parent |
object |
|
The parent business object. |
data |
object |
|
The data to load into the business object. |
eventHandlers |
Yes |
The event handlers of the instance. |
- Throws
-
Authorization error: The user has no permission to execute the action.
- Returns
-
ReadOnlyChildModelSync
The required read-only business object.
protectedcheckRules()
Executes all the validation rules of the business object, including the ones of its child objects.
This method is called by the parent object.
By default read-only business objects are supposed to be valid.
protectedfetch([data][, method])
Initializes a business object with data retrieved from the repository.
This method is called by the parent object.
Parameters
Name | Type | Optional | Description |
---|---|---|---|
data |
object |
Yes |
The data to load into the business object. |
method |
string |
Yes |
An alternative fetch method to check for permission. |
protectedgetBrokenRules([namespace]) → bo.rules.BrokenRulesOutput
Gets the broken rules of the business object.
This method is called by the parent object.
By default read-only business objects are supposed to be valid.
Parameter
Name | Type | Optional | Description |
---|---|---|---|
namespace |
string |
Yes |
The namespace of the message keys when messages are localizable. |
- Returns
-
bo.rules.BrokenRulesOutput
The broken rules of the business object.
protectedisValid() → boolean
Indicates whether all the validation rules of the business object, including the ones of its child objects, succeeds. A valid business object may have broken rules with severity of success, information and warning.
This method is called by the parent object.
By default read-only business objects are supposed to be valid.
- Returns
-
boolean
True when the business object is valid, otherwise false.
toCto() → object
Transforms the business object to a plain object to send to the client.
This method is usually called by the parent object.
- Returns
-
object
The client transfer object.
Events
postFetch
The event arises after the business object instance has been retrieved from the repository.
Parameters
Name | Type | Optional | Description |
---|---|---|---|
eventArgs |
|
Data portal event arguments. |
|
newObject |
|
The instance of the model after the data portal action. |
preFetch
The event arises before the business object instance will be retrieved from the repository.
Parameters
Name | Type | Optional | Description |
---|---|---|---|
eventArgs |
|
Data portal event arguments. |
|
oldObject |
|
The instance of the model before the data portal action. |