How do I Access Template properties in a new Servlet | Community
Skip to main content
August 14, 2017

How do I Access Template properties in a new Servlet

  • August 14, 2017
  • 1 reply
  • 1122 views

All my templates have a couple properties that are not getting imported into pages.  These properties need to be read to populate the SiteMap, they are Priority and Update Frequency.

The current com.adobe.acs.commons.wcm.impl.SiteMapServlet.java is looking for those properties in the page, not the template, and since they're not there, doesn't report them.  So I have 2 problems:

1)  In the CreatePage, I need to copy the values from the template into the page.  Reasonably straightforward, though I can't seem to hide the values from the user.  Currently, there is no requirement to allow anyone to change the values at the page level.

2)  For the pages generated prior to the 1) fix (call those legacy pages), I need to access the template properties.  I created a new SiteMapServlet called SiteMapServletMine which is a copy of SiteMapServlet (since it is final, I can't extend it).  I can access the Template from the Page, but cannot see how to access the properties in that template.

Note that a better* solution may be to write script to populate all the legacy pages from their templates, but that still begs the question, how do I access the properties?

* Better because then future changes to the template will not affect legacy pages.

I am using AEM 6.2

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

1 reply

smacdonald2008
Level 10
August 14, 2017

Can you give examples of what template props you need in a page that are not there. THis will help.

August 14, 2017

The template props are there, "sitemapPriority" (0.5) and "sitemapUpdateFrequency" (Weekly).  The SiteMapServlet looks for "changefreq" and "priority" in the page properties. The page properties (based on the RUNMODE) for "priority.properties" and "changefreq.properties" are empty, not 0.5 and Weekly.  Note that I also need to do a translation of the video URL for the SiteMap.  Is this what you are looking for?

smacdonald2008
Level 10
August 14, 2017

These are not typical template props that are set when creating a static template.

Templates - docs.adobe.com

Anyhow - if you need the values of these properties which are set a template node - you can use JCR API to retrieve the node and read the property values. I cannot think of another way other than querying these prop values.