Property

new EditableChildModel(parent[, eventHandlers])

Creates a new asynchronous editable child model instance.

The name of the model type available as: <instance>.constructor.modelType, returns 'EditableChildModel'.

Valid parent model types are:

 * EditableChildCollection
 * EditableRootModel
 * EditableChildModel

Parameters

Name Type Optional Description

parent

object

 

The parent business object.

eventHandlers

bo.shared.EventHandlerList

Yes

The event handlers of the instance.

Extends
ModelBase
Fires
EditableChildModel#event:preCreate
EditableChildModel#event:postCreate
EditableChildModel#event:preFetch
EditableChildModel#event:postFetch
EditableChildModel#event:preInsert
EditableChildModel#event:postInsert
EditableChildModel#event:preUpdate
EditableChildModel#event:postUpdate
EditableChildModel#event:preRemove
EditableChildModel#event:postRemove
Throws

Argument error: The parent object must be an EditableChildCollection, EditableRootModel or EditableChildModel 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 static
create(parent[, eventHandlers], callback)

Creates a new editable business object instance.
This method is called by the parent object.

Parameters

Name Type Optional Description

parent

object

 

The parent business object.

eventHandlers

bo.shared.EventHandlerList

Yes

The event handlers of the instance.

callback

external.cbDataPortal

 

Returns a new editable business object.

Throws

Authorization error: The user has no permission to execute the action.

Data portal error: Creating the business object has failed.

protected static
load(parent, data[, eventHandlers], callback)

Initializes an editable 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

bo.shared.EventHandlerList

Yes

The event handlers of the instance.

callback

external.cbDataPortal

 

Returns the required editable 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.

protected
childHasChanged()

Notes that a child object has changed.
This method is called by child objects.

protected
create(callback)

Initializes a newly created business object.
This method is called by the parent object.

Parameter

Name Type Optional Description

callback

external.cbDataPortal

 

Returns a new editable business object.

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 Optional Description

data

object

Yes

The data to load into the business object.

method

string

Yes

An alternative fetch method to check for permission.

callback

external.cbDataPortal

 

Returns the required editable business object.

fromCto(cto, callback)

Rebuilds the business object from a plain object sent by the client.
This method is usually called by the parent object.

Parameters

Name Type Optional Description

cto

object

 

The client transfer object.

callback

external.cbFromCto

 

Returns the eventual error.

protected
getBrokenRules([namespace]) → bo.rules.BrokenRulesOutput

Gets the broken rules of the business object.

This method is called by the parent object.

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.

getModelState() → string

Gets the state of the model. Valid states are: pristine, created, changed, markedForRemoval and removed.

Returns

string The state of the model.

isDeleted() → boolean

Indicates whether the business object will be deleted from the repository, i.e. its state is markedForRemoval.

Returns

boolean True when the business object will be deleted, otherwise false.

isDirty() → boolean

Indicates whether the business object itself or any of its child objects differs the one that is stored in the repository, i.e. its state is created, changed or markedForRemoval.

Returns

boolean True when the business object has been changed, otherwise false.

isNew() → boolean

Indicates whether the business object has been created newly and not has been yet saved, i.e. its state is created.

Returns

boolean True when the business object is new, otherwise false.

isSelfDirty() → boolean

Indicates whether the business object itself, ignoring its child objects, differs the one that is stored in the repository.

Returns

boolean True when the business object itself has been changed, otherwise false.

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.

Returns

boolean True when the business object is valid, otherwise false.

protected
keyEquals(data, getPropertyValue) → boolean

Determines that the passed data contains current values of the model key.

Parameters

Name Type Optional Description

data

object

 

Data object whose properties can contain the values of the model key.

getPropertyValue

internal~getValue

 

A function that returns the current value of the given property.

Returns

boolean True when the values are equal, false otherwise.

remove()

Marks the business object to be deleted from the repository on next save.

protected
save(connection, callback)

Saves the changes of the business object to the repository.
This method is called by the parent object.

Parameters

Name Type Optional Description

connection

object

 

The connection data.

callback

external.cbDataPortal

 

The business object with the new state after the save.

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

postCreate

The event arises after the business object instance has been initialized in the repository.

Parameters

Name Type Optional Description

eventArgs

bo.shared.DataPortalEventArgs

 

Data portal event arguments.

newObject

EditableChildModel

 

The instance of the model after the data portal action.

postFetch

The event arises after the business object instance has been retrieved from the repository.

Parameters

Name Type Optional Description

eventArgs

bo.shared.DataPortalEventArgs

 

Data portal event arguments.

newObject

EditableChildModel

 

The instance of the model after the data portal action.

postInsert

The event arises after the business object instance has been created in the repository.

Parameters

Name Type Optional Description

eventArgs

bo.shared.DataPortalEventArgs

 

Data portal event arguments.

newObject

EditableChildModel

 

The instance of the model after the data portal action.

postRemove

The event arises after the business object instance has been removed from the repository.

Parameters

Name Type Optional Description

eventArgs

bo.shared.DataPortalEventArgs

 

Data portal event arguments.

newObject

EditableChildModel

 

The instance of the model after the data portal action.

postUpdate

The event arises after the business object instance has been updated in the repository.

Parameters

Name Type Optional Description

eventArgs

bo.shared.DataPortalEventArgs

 

Data portal event arguments.

newObject

EditableChildModel

 

The instance of the model after the data portal action.

preCreate

The event arises before the business object instance will be initialized in the repository.

Parameters

Name Type Optional Description

eventArgs

bo.shared.DataPortalEventArgs

 

Data portal event arguments.

oldObject

EditableChildModel

 

The instance of the model before 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

bo.shared.DataPortalEventArgs

 

Data portal event arguments.

oldObject

EditableChildModel

 

The instance of the model before the data portal action.

preInsert

The event arises before the business object instance will be created in the repository.

Parameters

Name Type Optional Description

eventArgs

bo.shared.DataPortalEventArgs

 

Data portal event arguments.

oldObject

EditableChildModel

 

The instance of the model before the data portal action.

preRemove

The event arises before the business object instance will be removed from the repository.

Parameters

Name Type Optional Description

eventArgs

bo.shared.DataPortalEventArgs

 

Data portal event arguments.

oldObject

EditableChildModel

 

The instance of the model before the data portal action.

preUpdate

The event arises before the business object instance will be updated in the repository.

Parameters

Name Type Optional Description

eventArgs

bo.shared.DataPortalEventArgs

 

Data portal event arguments.

oldObject

EditableChildModel

 

The instance of the model before the data portal action.