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

Services and Tagging


Level 2

How do we write an OSGI Service that takes tag value and finds pages which are having tag value?

2 Replies


Community Advisor

Hello @Dvaraka 

You could use a service to use and pass desired tag id or path to get resources tagged with the tag.

Below is an example from 

private void populateTagListItems() {
        listItems = new ArrayList<>();
        String[] tags = properties.get(PN_TAGS, new String[0]);
        boolean matchAny = properties.get(PN_TAGS_MATCH, TAGS_MATCH_ANY_VALUE).equals(TAGS_MATCH_ANY_VALUE);
        if (ArrayUtils.isNotEmpty(tags)) {
            Page rootPage = getRootPage(PN_TAGS_PARENT_PAGE);
            if (rootPage != null) {
                TagManager tagManager = resourceResolver.adaptTo(TagManager.class);
                RangeIterator<Resource> resourceRangeIterator = tagManager.find(rootPage.getPath(), tags, matchAny);
                if (resourceRangeIterator != null) {
                    while (resourceRangeIterator.hasNext()) {
                        Page containingPage = pageManager.getContainingPage(;
                        if (containingPage != null) {

Also see look for method - getTagListItems


Level 2

Can you please elaborate the significance of 4th line of this code and also what are PN_TAGS_MATCH, TAGS_MATCH_ANY_VALUE??