Esta conversa foi bloqueada devido à inatividade. Crie uma nova publicação.
Nível 1
Nível 2
Faça login na Comunidade
Faça logon para exibir todas as medalhas
Esta conversa foi bloqueada devido à inatividade. Crie uma nova publicação.
I am using the below code to iterate the Node and update the property but it ends up loading the infinite loop.
resource -> launch.getResource().getChild("jcr:content")
Node node = resource.adaptTo(Node.class);
final NodeIterator it=node.getNodes();
do {
LOG.info("NODE PATH IS: "+node.getPath() );
node.setProperty(slingResourceType,conf/data/product/component);
node.getSession().save();
//it.nextNode();
}while(it.hasNext());
Is this the correct approach? It doesn't iterate from one node to other and print infinite time the log
Solucionado! Ir para a Solução.
Visualizações
respostas
Total de curtidas
Hi, here is combination of your code and other guys that shares advise in this thread
Resource resource = launch.getResource().getChild("jcr:content"); Node node = resource.adaptTo(Node.class); final NodeIterator it = node.getNodes(); while (it.hasNext()) { Node childNode = it.nextNode(); childNode.setProperty(slingResourceType,conf/data/product/component); } session.save();
In your original code you were referring to root node inside do..while loop instead of using node returned by nextNode(), this is why you only get jcr:content node. Please also be aware that getNodes() returns iterator for direct child nodes only.
If it still does not work for you, please share update code, for further analysis
Use while loop.
while(it.hasNext()) {
Node eachChildNode = it.nextNode();
eachChildNode.setProperty("...","...");
}
session.save();
Hi, here is combination of your code and other guys that shares advise in this thread
Resource resource = launch.getResource().getChild("jcr:content"); Node node = resource.adaptTo(Node.class); final NodeIterator it = node.getNodes(); while (it.hasNext()) { Node childNode = it.nextNode(); childNode.setProperty(slingResourceType,conf/data/product/component); } session.save();
In your original code you were referring to root node inside do..while loop instead of using node returned by nextNode(), this is why you only get jcr:content node. Please also be aware that getNodes() returns iterator for direct child nodes only.
If it still does not work for you, please share update code, for further analysis
Please check example at https://github.com/arunpatidar02/aem63app-repo/blob/master/java/GetChildNodeServlet.java
Visualizações
Curtida
respostas
Visualizações
Curtida
respostas