Jahia Dev Forum > How to create child...

0 (0 Good)
0 (0 Bad)

How to create child node inside parent node?

by  mohitbhunwalia »  2013/07/22 13:46

HI,

I am trying to add child node under parent node but getting the following error:-

javax.jcr.nodetype.ConstraintViolationException: No child node definition for jnt:css found in node /sites/demo/files.

I want to upload file under  /sites/demo/files/css. 

So how can I add  custom child node  "/css"  under parent node  "/sites/demo/files".   Please help me...

  • How to create child node inside parent node?
    2013/07/22 13:47

    mohitbhunwalia <p> HI,</p> <p> I am trying to add child node under parent node but getting the following error:-</p> <p> <strong>javax.jcr.nodetype.ConstraintViolationException: No child node definition for jnt:css found in node /sites/demo/files.</strong></p> <p> I want to upload file under <strong>&nbsp;/sites/demo/files/css.&nbsp;</strong></p> <p> So how can I add &nbsp;custom child node &nbsp;&quot;<strong>/css&quot;&nbsp;</strong>&nbsp;under parent node <strong>&nbsp;&quot;/sites/demo/files&quot;. &nbsp;</strong> Please help me<strong>...</strong></p>

  • Number of messages  15
    Registration date Jul 22, 2013
    0 (0 Good)
    0 (0 Bad)

    Re: How to create child node inside parent node?

    by  shyrkov »  2013/07/25 21:24

    Hello,

    in case you would like to create a sub-folder under folder /files and upload a file there you can do:

    JCRNodeWrapper cssFolder = session.getNode("/sites/demo/files").addNode("css", "jnt:folder");

    cssFolder.uploadFile("myFile.pdf", inputStream, "application/pdf");

    session.save();

     

    Kind regards

    Sergiy

  • Re: How to create child node inside parent node?
    2013/07/25 21:24

    shyrkov <p> Hello,</p> <p> in case you would like to create a sub-folder under folder /files and upload a file there you can do:</p> <p> JCRNodeWrapper cssFolder = session.getNode(&quot;/sites/demo/files&quot;).addNode(&quot;css&quot;, &quot;jnt:folder&quot;);</p> <p> cssFolder.uploadFile(&quot;myFile.pdf&quot;, inputStream, &quot;application/pdf&quot;);</p> <p> session.save();</p> <p> &nbsp;</p> <p> Kind regards</p> <p> Sergiy</p>

  • Number of messages  407
    Registration date Jul 25, 2013
    0 (0 Good)
    0 (0 Bad)

    Re: Re: How to create child node inside parent node?

    by  mohitbhunwalia »  2013/07/30 05:20

    Hi, 

    Sergiy

    Thank you very much. It's working for me. smiley


     

  • Re: Re: How to create child node inside parent node?
    2013/07/30 05:20

    mohitbhunwalia <blockquote> <p> Hi,&nbsp;</p> <strong>Sergiy</strong> <p> <span style="font-size: 12px;">Thank you very much. It&#39;s working for me.&nbsp;<img alt="smiley" height="20" src="https://www.jahia.com/modules/assets/javascript/ckeditor/plugins/smiley/images/regular_smile.gif" title="smiley" width="20" /></span></p> </blockquote> <br /> <p> &nbsp;</p>

  • Number of messages  15
    Registration date Jul 30, 2013
    Contact
    Share
    Feedback

    Get in touch

    Whether you are a current user or if you are just evaluating Jahia, we are here to help.

    Contact us

    Share this page