Hi,
I used a image component for creating a XF.
My custom image component will store the file reference as the child of the image node in content tree.
My model.json is not able to retrive the properties on the child node but only from the component node i.e image node.
Is there a way to include the child nodes of the component as well?
Solved! Go to Solution.
Views
Replies
Total Likes
Hi @bsr060893,
Could you please confirm if your custom image component has a Sling Model and Exporter is enabled on the same via annotation.
Below link explains how to enable a JSON export for a component.
There is nothing like default exporter.
XF page or Site page is accessible via "model.json" is because the respective page component has Sling Model with Exporter. Also the container components used within in turn has its own Sling Model with Exporter.
Given your existing set up, the only possible way to expose XF or Site Page as JSON would be to make use of JSON rendering of Sling Default Get Servlet. - "tidy.infinity.json or tidy.-1.json" which will expose the entire node structure with utmost depth. (To avoid custom implementation)
Hi @bsr060893,
Could you please confirm if your custom image component has a Sling Model and Exporter is enabled on the same via annotation.
Below link explains how to enable a JSON export for a component.
There is nothing like default exporter.
XF page or Site page is accessible via "model.json" is because the respective page component has Sling Model with Exporter. Also the container components used within in turn has its own Sling Model with Exporter.
Given your existing set up, the only possible way to expose XF or Site Page as JSON would be to make use of JSON rendering of Sling Default Get Servlet. - "tidy.infinity.json or tidy.-1.json" which will expose the entire node structure with utmost depth. (To avoid custom implementation)
Views
Replies
Total Likes
Hi @bsr060893,
Could you please let know which exact core component you tried.
Views
Replies
Total Likes
Views
Replies
Total Likes
Hi @bsr060893,
Core Image component both v1 and v2 saves the path as property (fileReference) and not as child node. Also if we observe the Core Image component model, this particular property is ignored in JSON via @JsonIgnore and other related properties are exposed.
As we are trying to get the JSON at XF level - xf page.model.json, it should be at respective page component model that we need to look into.
Exposing child node shouldn't be a problem. Perhaps in this context of exposing it via XF JSON as a whole might be a concern.
Next steps:
I suggest you to try Sling Model with exporter for your custom image component and try exposing at component level (This is to check if child node exposing is not a concern)
I will try in local in parallel and share my findings.
Views
Replies
Total Likes
Most of my components does not have the exporters.
I am trying to find if any default exporter java class is doing the job for the components and customizing the class to include the child nodes.
But i am unable to find the class.
Let know if any default model exporter handler for the components known.
Thank you
Views
Replies
Total Likes
Hi @bsr060893,
There is nothing like default exporter.
XF page or Site page is accessible via "model.json" is because the respective page component has Sling Model with Exporter. Also the container components used within in turn has its own Sling Model with Exporter.
Given your existing set up, the only possible way to expose XF or Site Page as JSON would be to make use of JSON rendering of Sling Default Get Servlet. - "tidy.infinity.json or tidy.-1.json" which will expose the entire node structure with utmost depth. (To avoid custom implementation)
Views
Replies
Total Likes
@bsr060893 : 'path' node is still part of the Image component , So you can use the below code to read the properties of the path node in Image Sling Model class. As the path node will not have any sling resource type, sling exporter will not process it automatically.
@Inject @Via(value = "path", type = ChildResource.class) String getPropertyName();
Hi @raghavc ,
I have many such components which doesn't have the model exporter and saves the content data as the child nodes under the component node in content tree.
Is there any generic solution for including he child nodes?
Views
Replies
Total Likes
Views
Replies
Total Likes
Some of the components are really old and not extending core components.
I am looking for a way customizing the json
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies