asset.js Script
The asset.js
script is the core component of any asset extension. This script allows business logic of an asset type to be altered with the use of several callback methods. The following sections explain the asset.js
script in detail:
Sample asset extension
The default asset extension for the Publisher is available in the <ES_HOME>/repository/deployment/server/jaggeryapps/publisher/extensions/assets/default/asset.js
file. While, the default asset extension for the Store is available in the <ES_HOME>/
repository/deployment/server/jaggeryapps/store/extensions/assets/default/asset.js
file.
Asset extension implementation
The asset.js
file of each asset extension is always processed in context of the default extension. The following diagram explains how this implementation works, where gadget is the example asset type.
The asset.js
script that corresponds to an asset extension (e.g., gadget asset extension) inherits callback methods from the default asset extension. In ES, you can use the asset.manager
callback method, which corresponds to the asset extension, to customize assets as ES treats this method as a special case. ES uses the generic asset manager implementation, which is in the RXT module, as the parent implementation. Therefore, as the callback methods are inherited from the default asset extension, a developer can choose to implement only some of the callback methods, or even choose not to define any of the callback methods in the asset extension. Thereby, if a developer does not define any callback methods, the callback methods in the default asset extension are invoked.
The asset extension behavior is implemented by first creating an instance of the generic asset manager, and then sequentially assigning the methods defined at the default and asset (e.g., gadget) levels as shown in the figure above. The default asset extension methods that are overridden by the asset extension (e.g., gadget asset extension) are placed in a special property referenced by _super
. For more information on how to call the parent implementation see, Example 2 - Calling the parent implementation when overriding a method.
Asset extension callback methods
The asset.js
script is the core of any asset extension. This script allows business logic of an asset type to be altered with the use of several callback methods, which are listed below:
Callback Method | Description |
---|---|
asset.manager | You can use this callback method to override the existing methods to handle the CRUD (create, read, update and delete) business logic of an asset type. For more information, see asset.manager Method Definitions. |
asset.server | You can use this callback method to create or override APIs and pages. Thereby, you can use this method to specify as to what URL structure the app should use. For more information, see asset.server Property Definitions. |
You can use this callback method to alter RXT properties and define meta properties (i.e., | |
asset.renderer | You can use this callback method to intercept calls to render operations such as, control page decorators (e.g., tag cloud, social meta information, rating). For more information, see asset.render Property Definitions. |