Child node path in javascript | Community
Skip to main content
varuns46785756
Level 5
March 16, 2017

Child node path in javascript

  • March 16, 2017
  • 2 replies
  • 5368 views

Hi,

I have images in dam in particular path.  like: content/dam/myproject/stateimage/image1.jpg....content/dam/myproject/stateimage/image2.jpg....

I am getting path through page property upto: content/dam/myproject/stateimage.

I am trying to iterate all the images path under this location(content/dam/myproject/stateimage.) in my component in javascript( serevr side script).Please suggest

 

 

Regards

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

2 replies

smacdonald2008
Level 10
March 16, 2017

If you want to use script to iterate through DAM Assets - much better to use JSP than JS. 

See" 

https://helpx.adobe.com/experience-manager/using/aem-dam-image-components.html

Why are you using JS to try and read JCR nodes? 

varuns46785756
Level 5
March 17, 2017

Hi

smacdonald2008 wrote...

If you want to use script to iterate through DAM Assets - much better to use JSP than JS. 

See" 

https://helpx.adobe.com/experience-manager/using/aem-dam-image-components.html

Why are you using JS to try and read JCR nodes? 

 

Hi Scott,

 

I am using slightly

My requirement is:  . I have one hero image component and : I am displaying different images on each page load and all the images present in dam.

I have asset folder name same as page name in dam.I am getting page path and trying to append the image in page path: like:

 page path :/content/myproject/mypage.html

dam path: /content/dam/myproject/mypage/myimage1.jpg,/content/dam/myproject/mypage/myimage2.jpg

trying to get the image path by server side script.

Regards,

varuns46785756
Level 5
March 22, 2017

Are the image-paths stored on the hero-image component?


All images stored in dam , at: dam path: /content/dam/myproject/mypage

images  dam path: /content/dam/myproject/mypage/myimage1.jpg,

                                     /content/dam/myproject/mypage/myimage2.jpg

 I need to iterate all images from this location  /content/dam/myproject/mypage to my component

 

 

Regards,

Runal_Trivedi
Level 6
March 17, 2017

you should either have your JSP write the child assets in that folder as data attribute and you can use it then in your JS as needed.

OR

You can write a servlet to return all the child asset paths under your folder, make the Ajax call from JS to the servlet and use the response array as you want.

I will suggest you to take the servlet route, as with JSP once your page gets cached, then you won't be able to get the updated list of assets on any new addition of that asset under that dam folder.

~ Runal