sivaprasad9394
Occasional Collector

How to get the children for the pagereffolder?

Jump to solution

Hello Team,

How to get the children(pagerefs and pagereffolders) for a specific pagereffolder?

Which method should i use to get it?

FS Version: 5.2.220210

SiteStoreRefFolder.png

BeanShell_Code.png

1) bsh % e.getChildCount(); --- 3

2) bsh % e.getChildren().toList();
<[<LANG displayname="single_folder" language="EN"/>
, <NODE_LANG_SPEC label="single_folder" language="EN"/>
, <NODE_LANG_SPEC label="single_folder" language="DE"/>
]>

3) bsh % e.getChildren().toList().size();
<3>
4) bsh % e.getFirstChild().getChildren().toList().size();
<0>

But for me pagereffolder has no elements in it.Its an empty folder.

How no 3 is displaying in console result? Output should be 0 right?

Thanks and Regards,

Siva

 

0 Kudos
1 Solution

Accepted Solutions
mbergmann
Crownpeak employee

Hi Siva,

the reason you get 3 ist that „technically“ also some additional information like label names of the folder are considered „children“. So you you have to check for the type of the elements.

Michael

View solution in original post

2 Replies
mbergmann
Crownpeak employee

Hi Siva,

the reason you get 3 ist that „technically“ also some additional information like label names of the folder are considered „children“. So you you have to check for the type of the elements.

Michael

Hello Bergmann,

Thank you for your reply. Any how only 2 types are available here in sitestorefolder. As you have mentioned in previous thread it can be achieved like below,

 

bsh % import de.espirit.firstspirit.access.store.sitestore.PageRef;
bsh % e.getChildren(de.espirit.firstspirit.access.store.sitestore.PageRef.class);
<de.espirit.firstspirit.store.access.AbstractStoreElement$StoreElementListable@68bb0f20>
bsh % e.getChildren(de.espirit.firstspirit.access.store.sitestore.PageRef.class).toList();
<[]>
bsh % import de.espirit.firstspirit.access.store.sitestore.PageRefFolder;
bsh % e.getChildren(de.espirit.firstspirit.access.store.sitestore.PageRefFolder.class).toList();
<[]>
bsh %

 

Thank you,

Siva

 

 

0 Kudos