Go to content

Components in my blog: Properties component

Published on

This blogpost is about the Hippo Forge Properties component. This component allows you to manage labels for your website instead of hardcoding them into the JSP.

My website is mostly an extended version of the Hippo Site Toolkit demo project. I did a complete HTML and CSS (re)design but the core components look a lot like the original demo. My blogpost document type contains only a few more fields for keywords and keyword suggestions compared to the original text document. In the comment document type I added fields so you can fill in your email address (which I will never publish) and website (which I will publish unless you’re trying to send spam).

The properties component is extremely useful to avoid hard coded labels in your rendering templates, in my case the JSP’s. The values of the labels are managed from the CMS so if you want to change a common navigation element like "previous" to "previous page" you don’t have to do a new deploy of your site. At this moment it is used for the labels of the month facets when navigating through the blogposts. The faceted navigation returns values from 0 to 11 but I rather display them as January to December.

After adding the properties component to the CMS you get a new document type for maintaining the properties. This document type contains repeating key-value pairs, e.g. "month.0" as key for label "January". Then add the necessary dependencies and configuration to the site project. In your own default component or in a specific component add the code that adds the key-value pairs to the request for the rendering templates. You can find examples in the documentation how to add this to your own site. In my case I added it to the HST component that handles the listing of the faceted navigation.

This is what my JSP code looks like to display the label of a month:

<c:set var="labelkey" value="month.${facetvalue.name}" />
${labels[labelkey]}