cancel
Showing results for 
Search instead for 
Did you mean: 

I created a child node but I cannot see it from its parent

johnhelen
Champ in-the-making
Champ in-the-making
Hello

I create a child nodeRef from a parentNode by using the code


Map<QName, Serializable> reportProps = new HashMap<QName, Serializable>(4, 1.0f);
      reportProps.put(WCMAppModel.PROP_DEPLOYSERVER, serverUri);
      reportProps.put(WCMAppModel.PROP_DEPLOYVERSION, version);


NodeRef childNode = nodeService.createNode(parentNode,
                          WCMAppModel.ASSOC_DEPLOYMENTREPORTS, WCMAppModel.ASSOC_DEPLOYMENTREPORTS, WCMAppModel.TYPE_DEPLOYMENTREPORT, reportProps).getChildRef();



Now I want to know if the parentNode has a child nodeRef or not, I use this code:


List<ChildAssociationRef> children = nodeService.getChildAssocs(parentNode, ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL);
          
      for (ChildAssociationRef childAssoc : children) {
          NodeRef childRef = childAssoc.getChildRef();
          logger.debug("Parent NodeRef has: " + childRef);
      }


I think that the size of children must be 1. However, children always empty
I did something wrong here to get the children nodes? Could you please help

Many thanks
1 REPLY 1

mrogers
Star Contributor
Star Contributor
yes - you have a mismatch in your assoc name….