Create name-value pairs in Publisher

AquaLogic Publisher has a reasonably powerful scripting language for creating dynamic HTML files in the WebCenter Interaction portal.  After you define a Data Entry Template and Presentation Template, you can create Content Items to use those templates and render whatever HTML you want – or any other text-based file, like RSS (login required).

Data Entry Templates can contain fields of many types, such as text, rich text, numbers, dates, and selection lists.  But one thing it doesn’t have is the ability to create “name-value” pairs.  For example, recently I had a list of government agencies and I wanted to use the acronym for that agency in some places, and the full text in others.  I could force users to type in the text in two different fields or even provide them with two different selection lists, but since an acronym can only mean one agency, it would be easier to include both in a single drop-down list.  Drop-down lists, however, only allow plain text in them, and I needed a way to map the acronym to the agency.

So, I used the “substring” function in Presentation Templates to “fake” this.  Basically, for each item in the selection list, I allocated 10 characters to the acronym itself; the 11th character was the start of the full agency name.  In the drop-down list for the Content Items, the extra spaces are ignored and the user simply selects the agency:


… but in the Presentation Template, we use the “substring” method to grab the first 10 characters for the acronym, and anything after that for the name:


Agency Acronym: <pcs:value expr="substring(project.department,0,10)">
Agency Name: <pcs:value expr="substring(project.department,10)"&gt;

In this way, once published, the Content Items allow all sorts of fancy displays; in my case I used Javascript to dynamically display and filter a table based on the various agencies by name, but used the acronymn in the table itself:


Tags: , , ,

Leave a Reply