...
In some cases the default name matching between properties and fields is not enough, e.g. if you want to map jcr:title
property. In such cases you can specify a name of a property from which to read the value. You can do this specifying the String argument in @JcrProperty
which will instruct mapper to read a property of specified name.
...
It processes fields which are annotated with com.cognifide.slice.mapper.annotation.SliceReference
. It allows for mapping of models from a different resource (path) than a current resource
The @SliceReference
annotation takes a path as a value. The value can be either an absolute path (like /content/test/home/jcr:content/par
) or child path (like childResource/grandChildResource
) - then it will be resolved relatively to current resource. Bear in mind that parent resources (like ../../test
) are not supported.
The value of a path can contain placeholders in form of: ${placeholderName}
. This can be useful when the path is dynamic and changes depending on request, e.g. contains language. Instead of hardcoding the language in the path (like: /content/site/en/home
), you can put placeholder and have this path to be dynamically evaluated, e.g. /content/site/${language}/home
.
...
Code Block | ||
---|---|---|
| ||
@SliceResource public class MyComponentModel { @JcrProperty private String property; @Inject private ModelProvider modelProvider; @PreMapping public void preMapping() { // modelProvider is already set; property is not set } @PostMapping public void postMapping() { // modelProvider and property are already set } } |
How to extend mapper?
Writing your own processor
...
Include Page | ||||
---|---|---|---|---|
|