fcf.NClient.Wrapper class
[Client only] Template wrapper class on client
Class description
In addition to declared methods, Wrapper objects support methods to handle template argument change.
The onArg method is called whenever the template argument changes:
onArg(string a_argName, mixed a_value, fcf.NClient.Wrapper a_editor, bool a_ignoreRedrawing, bool a_innerCall, string a_suffix)
The onArg[ARGUMENT_NAME] method is called every time the template argument changes, and with the name ARGUMENT_NAME:
onArg[ARGUMENT_NAME](mixed a_value, fcf.NClient.Wrapper a_editor, bool a_ignoreRedrawing, bool a_innerCall, string a_suffix)
ARGUMENT_NAME - The argument name starts with a capital letter.
Arguments:
string a_argName - Argument name
mixed a_value - The new value to be set.
fcf.NClient.Wrapper a_editor - The object on which the setArg method was called. When applying links, a_editor and this may not be equal
bool a_ignoreRedrawing - Redrawing prohibiting flag
bool a_innerCall - The internal call flag from the template itself is used to build internal processing.
string a_suffix - The path of the modified value in the argument.
Example:
...
onArgValue(a_value, a_editor, a_ignoreRedrawing, a_innerCall, a_suffix){
if (this.isChild(a_editor) && this.getArg("defaultFlag")){
this.setArg("defaultFlag", false);
}
}
...
Methods
attach(object a_options) - The method is called every time the template is linked to the wrapper. This method is used in inherited classes.
array check() - Validates the template data and returns an array of objects with error information
destroy() - Deletes the template and the data associated with it
fcf.Actions initialize() - Initializes the object. After its execution, all child elements will also be initialized and ready for use.
recalculate() - Performs simplified argument recalculation. Only tokenizing arguments declared via fcf.argVal() are recalculated
fcf.Actions reload() - Redraws the template with a complete recalculation of the arguments. The initial values of the arguments are recalculated.
fcf.Actions update() - Recalculates and redraws the template based on the current state of the arguments. The update algorithm depends on the clientRendering template option.
fcf.Actions update(object a_options) - Recalculates and redraws the template based on the current state of the arguments. The update algorithm depends on the clientRendering template option.
Methods
attach(object a_options)
The method is called every time the template is linked to the wrapper. This method is used in inherited classes.
Arguments:
object a_options - [Since 1.1.55] Parameters for calling the element's DOM binding.
boolean updateStatic - This argument is used when the "static" template option is true (does not update DOM elements). In "static" mode, the attach method is called on every update to allow parsing of the recalculated arguments. The updateStatic property is set to true (in "static" mode) when the element's DOM was updated, this happens when redrawing by the reload method.
boolean first - equals true the first time the attach method is called
array check()
Validates the template data and returns an array of objects with error information
Return value:
array
Array of objects with information about errors in validating data from the current state of the template
Object fields with error information:
- string id - template id
- string alias - template alias
- ErrorObject error - error object
destroy()
Deletes the template and the data associated with it
Event emit(object a_data, string|Event a_event)
Sends a Dom event to the wrapper
Arguments:
object a_data - An object with the values of additional event fields
string|Event a_event - Event name or event object
Return value:
Event
DomElement getActionDomElement()
Returns the Dom element of the template actions. The template's Dom events pass through this element.
Return value:
DomElement
Dom element of template actions
string getAlias()
Returns alias template
Return value:
string
Alias template
mixed getArg(string a_path)
Returns the value of the template argument
Arguments:
string a_path - The data path of the template argument. Path elements can be separated by a point or by an object element access format using the ["ELEMENT"] construct.
Examples:
wrapper.getArg('arg1')
wrapper.getArg('arg1.name')
wrapper.getArg('arg1["name"]')
Return value:
mixed
object getArgs()
Returns an object with the values of the template arguments
Return value:
object
fcf.NClient.Wrapper getChild(string a_alias)
Returns the child wrapper by alias name
Arguments:
string a_alias - Alias of the child template
Return value:
fcf.NClient.Wrapper
Child wrapper
[fcf.NClient.Wrapper] getChilds()
Returns an array of child template wrappers
Return value:
[fcf.NClient.Wrapper]
Array of child elements
DomElement getDomElement()
Returns Dom element of the template
Return value:
DomElement
fcf.NClient.Wrapper getFirstChild()
Returns the first child wrapper of the template
Return value:
fcf.NClient.Wrapper
string getId()
Returns template id
Return value:
string
template id
object getOptions()
Returns an object with template option values
Return value:
object
Object with template option values
fcf.NClient.Wrapper getParent()
Returns the parent wrapper
Return value:
fcf.NClient.Wrapper
Parent wrapper
string getTemplate()
Returns template name
Return value:
string
Template name
fcf.Actions initialize()
Initializes the object. After its execution, all child elements will also be initialized and ready for use.
Return value:
fcf.Actions
Promise object indicating completion of execution
bool isChild(fcf.NClient.Wrapper a_wrapper)
Returns true if the object is the owner of a_wrapper
Arguments:
fcf.NClient.Wrapper a_wrapper - The object being checked
Return value:
bool
bool isOwn(fcf.NClient.Wrapper a_wrapper)
Returns true if the object being checked is nested in the wrapper or is this object
Arguments:
fcf.NClient.Wrapper a_wrapper - The object being checked
Return value:
bool
lock()
Locks the template
recalculate()
Performs simplified argument recalculation. Only tokenizing arguments declared via fcf.argVal() are recalculated
fcf.Actions refresh()
fcf.Actions refresh(object a_options)
Redraws the template and returns the arguments to the values equal to the initial values
Arguments:
object a_options - [Since 1.1.55] Template update options
boolean updateStatic - If true, then DOM elements are updated for templates with the "static" option set.
Return value:
fcf.Actions
fcf.Actions reload()
Redraws the template with a complete recalculation of the arguments. The initial values of the arguments are recalculated.
Return value:
fcf.Actions
NodeList select(string a_selector)
Selects Dom elements inside the current template
Arguments:
string a_selector - The selection rules defined by the method document.querySelectorAll()
Return value:
NodeList
fcf.Actions->mixed send(object a_data, [FileList|DomElement{input type=file}] a_files = undefined)
Performs the server-side action defined in the [TEMPLATE].receive.js file
Arguments:
object a_data - Data sent to the server
[FileList|DomElement{input type=file}] a_files - Array with FileList objects storing files sent to the server or DOM input elements of type file
Return value:
fcf.Actions->mixed
Returns fcf.Actions with the result of processing data on the server side
setArg(string a_path, mixed a_value, bool a_ignoreCallbacks = false, bool a_ignoreRedrawing = false, bool a_innerCall = false)
Sets the value of the template argument
Arguments:
string a_path - The data path of the template argument. Path elements can be separated by a point or by an object element access format using the ["ELEMENT"] construct.
Examples:
wrapper.setArg('arg1', 'new value')
wrapper.setArg('arg1.name', 'new value')
wrapper.setArg('arg1["name"]', 'new value')
mixed a_value - The specified value of the argument
bool a_ignoreCallbacks - If set to true, the handlers for changing the onArg argument are not called
bool a_ignoreRedrawing - If true, the template is not updated (it should not be rendered)
bool a_innerCall - The parameter is passed to the onarg template argument handler to define an internal call from the wrapper code
unlock()
Unlocks the template
fcf.Actions update()
fcf.Actions update(object a_options)
Recalculates and redraws the template based on the current state of the arguments. The update algorithm depends on the clientRendering template option.
Arguments:
object a_options - [Since 1.1.55] Template update options
boolean updateStatic - If true, then DOM elements are updated for templates with the "static" option set.
Return value:
fcf.Actions
validate(mixed a_value, object a_options, array a_dsterrors)
Checks the value for validity. The validation is performed based on template arguments, which are interpreted as the values of the SQL field description.
Arguments:
mixed a_value - Value to check
object a_options - Object of additional validation parameters.
Object fields
- bool secondPriority = false - If true the not Null constraints are ignored
array a_dsterrors - An array in which objects with information about validation errors are written.
Object fields with error information:
- string id - template id
- string alias - template alias
- ErrorObject error - error object