You can simply use the PageManager API , check http://dev.day.com/docs/en/cq/current/javadoc/index.html for more detail on the PageManager
You can get a page manager from a resource resolver object via .adaptTo()
Hope this help.
Thanks for the reply. Can you please tell me what is adapTo() us used for? I have seen below code:
Resource r = slingRequest.getResourceResolver().getResource(rootPath);
Node rootNode = r.adaptTo(Node.class);
what does above code means? What is rootPath? Can I give any path here and it will fetch the resource or say that node? what is the meaning of adaptTo and then passing the Node.class?
I created using JcrUtil class. What i did is, I created one sample Page at UI level and then using JcrUtil I copy that page and change the basic property like title, name and page specific component. below is the code I used:
session = currentNode.getSession();
//getting the dummy page which I created at UI level
Node productNode = currentNode.getParent().getParent().getNode("product");
//copy the dummy page at the same level of "product" page, for that I am using getParent()
newNode = JcrUtil.copy(productNode,productNode.getParent(),node.getProperty(name).getString());
//Updating the values in tthis new Page for Product Node. IF we don't change then it will be same as old node
newNode = newNode.getNode("jcr:content").getNode("productForm");
adaptTo is a nice framework that is part of the Apache Sling key concept I would say, if you missed that you need to re-read about Apache Sling in general.
The code you mentioned is simple, it mean it get the resource at the given path and try to transform the resource to another object (a Node in this case).
I have the feeling that you didn't get the basic training of CQ / Apache Sling, it would make sense that you check for that first.
Generally using the JCR api is fine, but in CQ there are some utility classes/services (like the PageManager) that help you to make sure that you create the content with the expected structure, so I would suggest you to use
Yes you are right, I jsut started learning on my own. I read through the java doc/Geometrixx site and some online content.
Let me know if you have some good startup training links. Also feel free to give your suggetions for any other thing which you feel I should read. Thanks in advance.
And I will sure go through the adaptTo and apache Sling.