I discovered that you can add HTML tags to properties and later use <h:outputFormat>
to fetch these properties with parameters. Also, you can do pretty neat stuff with property files as described in MessageFormat API.
My solution was to keep the .xhtml
files inside the WAR, but use simple HTML snippets properties from the default resource bundle which is based on a .properties
file. These properties were included in the .xhtml
using <h:outputFormat>
and <h:outputText>
. This allows the user to add simple styling like bold and underline to the snippets.
The properties file are copied to the Jetty resource
folder using the custom Maven plugin, so I have kept the .properties
files in the WAR. For some reason the Jetty resource
folder has precedence over the packed .properties
files, so this works out fine. Also, as Akber pointed out, I will have the default versions of the properties available if for some reason the WAR was moved to some other application server where the resource
folder is not available.
Of course, with this approach the code can break if malformed HTML is placed inside the snippet properties, as pointed out by Akber, but it works for our application as it is very small. I may never have done this if this was a much larger application, but then I might have gone for a database based solution for adding static text (like Joomla/Drupal/Wordpress).