Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Child node path in javascript

varuns46785756
Level 5
Level 5

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

6 Replies
smacdonald2008
Level 10
Level 10

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
Level 5

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
Level 5

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
Community Advisor
Community Advisor

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