Implement a standard module
Level: intermediate
Example
Create a standard module that contains the init()
and render()
methods. When loading the module, the client core must call the init()
method, then the render()
method. Each method must call a message box.
Create a visual module
-
Open the Configuration section and select a custom package to add the schema.
-
Click Add → Module on the section list toolbar.
-
Fill out the schema properties in the Module Designer.
- Set Code to "UsrExampleStandardModule."
- Set Title to "ExampleStandardModule."
Click Apply to apply the changes.
-
Add the source code in the Module Designer.
UsrExampleStandardModule/* Declare a module called UsrExampleStandartModule. The module has no dependencies. Therefore, an empty array is passed as the second module parameter. The factory function returns a module object that has two methods. */
define("UsrExampleStandardModule", [], function () {
return {
/* The client core calls this method first automatically when loading the module. */
init: function () {
alert("Calling the init() method of the UsrExampleStandardModule module");
},
/* The client core calls this method automatically when loading the module into a container. A link to the container is passed to the method as a renderTo parameter. The message box displays the ID of the page control that displays the visual module data. By default, centerPanel. */
render: function (renderTo) {
alert("Calling the render() method of the UsrExampleStandardModule module. The module is uploaded to the container " + renderTo.id);
}
};
}); -
Click Save on the Module Designer’s toolbar.
Outcome of the example
To view the outcome of the example, create the following request string.
- Template URL
- Example URL
[Creatio URL]/0/NUI/ViewModule.aspx#[SomeModuleName]
http://myserver.com/0/NUI/ViewModule.aspx#UsrExampleStandardModule
When loading the module, the client core must call the init()
method, then the render()
method. Each method calls a message box.