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

SOLVED

Sling Model Multivalue Page level property reading

khamat_bn
Level 4
Level 4

Hello Guys,

I want to read the property of page level cq:tags which will be multivalue. If I trying to read the property by 

pageNodes.getProperty("cq:tags").getValue().toString()

its saying cq:tags is multivalue. can anyone tell me how i can read this property.

 

Regards,

~BK

 

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution
khamat_bn
Correct answer by
Level 4
Level 4

Hello @a74048191r ,

Thanks for the response, I tried the lines that u posted. Unfortunately, it didn't work for me.

But I ended up with the solution that works for me. Posting Here so others can also use it if required.

private Value[] tagsFromPage;

for
(Value eachTag : tagsFromPage) {
log.info("tagsFromPage value: {}", eachTag.toString());
}

 

View solution in original post

0 Replies
a74048191r
Level 2
Level 2

try this:

Value[] values = pageNodes.getProperty("cq:tags").getValues();
 
then iterate as needed

                for (Value value : values) {
                    Tag tag = tagManager.resolve(value.getString());
                }
khamat_bn
Correct answer by
Level 4
Level 4

Hello @a74048191r ,

Thanks for the response, I tried the lines that u posted. Unfortunately, it didn't work for me.

But I ended up with the solution that works for me. Posting Here so others can also use it if required.

private Value[] tagsFromPage;

for
(Value eachTag : tagsFromPage) {
log.info("tagsFromPage value: {}", eachTag.toString());
}