new ReadOnlyChildModel(parent, eventHandlers)
Creates a new asynchronous read-only child model instance.
The name of the model type available as: <instance>.constructor.modelType, returns 'ReadOnlyChildModel'.
Valid parent model types are:
* ReadOnlyRootCollection
* ReadOnlyChildCollection
* ReadOnlyRootModel
* ReadOnlyChildModel
* CommandObject
Parameters:
Name | Type | Argument | Description |
---|---|---|---|
parent |
object | The parent business object. |
|
eventHandlers |
bo.shared.EventHandlerList |
<optional> |
The event handlers of the instance. |
Fires:
Throws:
-
Argument error: The parent object must be a ReadOnlyRootCollection, ReadOnlyChildCollection, ReadOnlyRootModel, ReadOnlyChildModel or CommandObject instance.
-
Argument error: The event handlers must be an EventHandlerList object or null.
Extends
Members
-
<readonly> $modelName :string
-
The name of the model. However, it can be hidden by a model property with the same name.
Type:
- string
Methods
-
<protected, static> create(parent, eventHandlers, callback)
-
Creates a new read-only business object instance.
This method is called by the parent object.Parameters:
Name Type Argument Description parent
object The parent business object.
eventHandlers
bo.shared.EventHandlerList <optional>
The event handlers of the instance.
callback
external.cbDataPortal Returns a new read-only business object.
-
<protected, static> load(parent, data, eventHandlers, callback)
-
Initializes a read-only business object width data retrieved from the repository.
This method is called by the parent object.Parameters:
Name Type Argument Description parent
object The parent business object.
data
object The data to load into the business object.
eventHandlers
bo.shared.EventHandlerList <optional>
The event handlers of the instance.
callback
external.cbDataPortal Returns the required read-only business object.
Throws:
Authorization error: The user has no permission to execute the action. -
<protected> checkRules()
-
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.
-
<protected> fetch(data, method, callback)
-
Initializes a business object with data retrieved from the repository.
This method is called by the parent object.Parameters:
Name Type Argument Description data
object <optional>
The data to load into the business object.
method
string <optional>
An alternative fetch method to check for permission.
callback
external.cbDataPortal Returns the required read-only business object.
-
<protected> getBrokenRules(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.
Parameters:
Name Type Argument Description namespace
string <optional>
The namespace of the message keys when messages are localizable.
Returns:
The broken rules of the business object.
-
<protected> isValid() → {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:
True when the business object is valid, otherwise false.
- Type
- boolean
-
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:
The client transfer object.
- Type
- object
Events
-
postFetch
-
The event arises after the business object instance has been retrieved from the repository.
Parameters:
Name Type Description eventArgs
bo.shared.DataPortalEventArgs Data portal event arguments.
newObject
ReadOnlyChildModel 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 Description eventArgs
bo.shared.DataPortalEventArgs Data portal event arguments.
oldObject
ReadOnlyChildModel The instance of the model before the data portal action.