Can String be converted to Node since I do not want to use node iterator ?
Solved! Go to Solution.
Views
Replies
Total Likes
you could directly return the list from your sling model and iterate it on sightly.
No matter what kind of object it is (string or node), a data-sly-list would iterate it for you and once you hold the instance of the object, you can retrieve the values.
Hi @chinmayis865517 ,
I am assuming by String you mean you have resource path to which you want to adapt as Node. One way would be is -
Map<String, Object> param = new HashMap<>();
param.put(ResourceResolverFactory.SUBSERVICE, "myservice");
ResourceResolver resourceResolver = resolverFactory.getServiceResourceResolver(param);
Resource res = resourceResolver.resolve("MY_PATH");
Node n = res.adaptTo(Node.class);
Though I would recommend to use Sling API instead of using JCR APIs until you have a strong use case of using JCR.
Thanks,
Ritesh Mittal
Hi @Ritesh_Mittal ,
Thank you for the reply.
Currently a list of string is being stored in List <String> object. This itemList is used to iterate the sly-resource of a component. There's no resource path being used . I have used currentNode and am iterating through the child nodes but the page load time has increase a lot because of this even though the solution is working.
If you could tell us about this String object and what it holds(value), what are you trying to achieve, based on that we can provide code snippet.
Hi @DEBAL_DAS ,
Thank you for the reply.
Currently a list of string is being stored in List <String> object. This itemList is used to iterate the sly-resource of a component. There's no resource path being used . I have used currentNode and am iterating through the child nodes but the page load time has increase a lot because of this even though the solution is working.
you could directly return the list from your sling model and iterate it on sightly.
No matter what kind of object it is (string or node), a data-sly-list would iterate it for you and once you hold the instance of the object, you can retrieve the values.
Views
Likes
Replies
Views
Likes
Replies