Resolving custom type from a SyntheticResource
Hi AdobeTeam,
I have created
- a custom resource type which is inherited from the core resource type "core/wcm/components/navigation/v2/navigation",
- the respective Sling model exporter which contains the following annotation:
@Self@Via(type = ResourceSuperType.class)
private Navigation navigation;
I would like to get the json Sling model for my custom resource generated by calling it from a SlingAllMethodsServlet which gets the navigation attributes in query parameters. To do that I created a SyntheticResource (i.e. ValueMapResource) where I pass some Navigation parameters for the model.
Doing it like this:
...
properties.put(PN_NAVIGATION_ROOT, navigationRoot);
properties.put(PN_STRUCTURE_START, structureStart);
ValueMapResource syntheticResource = new ValueMapResource(resourceResolver, "/syntheticResourcePath", RESOURCE_TYPE, properties);
...
The correct model is found and created by the factory but the
@Self @2434638(type = ResourceSuperType.class) private Navigation navigation
instance variable in the model is null.
I debugged the resolution of the model for a long time and seems that although the correct core Adobe Navigation implementation is found but some variables in it can not be resolved, i.e.:
* The current page.
*/
@ScriptVariable
private Page currentPage;
/**
* The current style.
*/
@ScriptVariable
private Style currentStyle;
These missing variables in the parent core Navigation model must cause the @Self Navigation variable to be null.
Can you help me what I should set in my ValueMapResource / request so that the currentPage and currentStyle variables can be resolved in the SlingBindings (that's where those variables are contained but holding null value)?
Thanks,
Peter