It depends what kind of sub nodes it has.
Try to use getChildren(ItemType.YOUR_NODE_TYPE);

ItemType is a class which defines default magnolia nodetypes like
CONTENT -> mgnl:content (a page in website repository has type mgnl:content)
CONTENTNODE -> mgnl:contentNode (its a paragraph)


Hope this helps
Regards
- Sameer





On Nov 17, 2006, at 10:04 AM, Ducret, Gilles (CH) wrote:

 Hello,

We want to access the different paragraphs of a page to print it. We have written a servlet that is being called with a page parameter. But when accessing the page, and browsing the paragraphs we don't get any children.

If we do the opposite. We directly go to the paragraph and walk up through the containers we can access the page.

I copy the code in this email. If somebody could tell us what is wrong in the code.

Many thanks

// In the JSP tag of the source page
String page = info.magnolia.cms.util.Resource.getActivePage (request).getHandle();
// Then I call the servlet with the page parameter

// The servlet code
Content content = MgnlContext.getHierarchyManager (ContentRepository.WEBSITE).getContent(request.getParameter("page")); log.debug("Page handle : " + content.getHandle()) ; // OK it return the page handle
if (content.getChildren().iterator().hasNext()) {
log.debug("Page children handle : " + ((Content) content.getChildren ().iterator().next()).getHandle()); // KO No children found
} else {
log.debug("Page children not found");
}

There is no children in my iterator. It's strange because when I try to browse nodes from the paragraph to the paragraph container I can reach the children :


Regards,

Sameer Charles
Magnolia International Ltd.

------------------------------------------------------------------------ ---------
[EMAIL PROTECTED]       http://www.magnolia.info
Magnolia®  - Simple Enterprise Content Management
------------------------------------------------------------------------ ---------







----------------------------------------------------------------
for list details see
http://www.magnolia.info/en/magnolia/developer.html
----------------------------------------------------------------

Reply via email to