SLING-INF.repository-content.neba.js Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of io.neba.neba-core Show documentation
Show all versions of io.neba.neba-core Show documentation
Contains the entire NEBA core implementation, i.e. the framework that interprets the
NEBA API annotations and provides implementations for the service and lifecycle callback
interfaces provided in the NEBA API. This package must not export anything as
its implementation details are entirely private.
/**
* Provides the most specific resource model for the current resource. Can be used like so:
*
* <... data-sly-use.m="/apps/neba/neba.js" ...>
* ${m.someProperty}
*
* To explicitly specify a model name, use
*
* <... data-sly-use.m='${"/apps/neba/neba.js" @ modelName="name"}'...>
*
* @deprecated Using this script to automatically to adapt to the most specific model is deprecated
* as it introduces implicit and intransparent coupling between a view and a model. This coupling is
* easily broken by introducing a new model for the same resource type. This is almost impossible to foresee and
* hard to fix. Thus, instead of using this script, explicitly adapting the resource to the desired model is advised.
* @param modelName the optional specific name of the model bean to adapt the current resource to
*/
use(function () {
// Java packages are accessed from JS using Packages.
var service = sling.getService(Packages.io.neba.api.services.ResourceModelResolver);
if (service == null) {
return null;
}
return this.modelName == null ?
service.resolveMostSpecificModel(resource) :
service.resolveMostSpecificModelWithName(resource, this.beanName);
});