For a while now one of the items on my wish-list of functionality to add to XPages has been the facility for the user to change the theme of an XPages application, possibly even for individual users to select a theme for their own experience. Currently, you need Domino Designer to change the theme for the web (fortunately now free, but still needing to installed).
There is the option of assigning a stylesheet to each page (or a custom control on every page) that is computed based on a sessionScope or applicationScope variable.
So my next thought was to track down where the theme is set. I initially found it in the Icon, as with many other database-level properties (database title, template name etc.). Unfortunately, although there is indeed a $DBTheme field in the Icon, it appears to be the client theme.
So I set my theme and did a search. Sure enough, I found it in xsp.properties, a file only accessible through the Java perspective. But nevertheless it exists in the .nsf, so it must be possible to get a handle on it, right? A few agents later, I managed to export it as DXL by creating a NotesNoteCollection with SelectMiscFormatElements set to true, and looping through them. (Incidentally, this is also where XPages and Custom Controls can be found).
So I’d got my DXL out, worked out how to encode the theme using Base64, and trying to import it back in. But I hit my final stumbling block. After many attempts, all I could get was the message “Document has invalid structure”, even though it follows the same format as the output. The output and agent are attached, in case anyone can get any further with them. My plan was to store the theme in a profile document and kick of a server-triggered agent to do the import, getting round the problem of needing Designer access.
My fall-back position (prompted as I began writing this article) has been to have a single theme with the different stylesheets rendered according to scoped variables, like this (note, you need to escape the ampersands in the XML):
Is this a good approach? Are there better practice approaches?
I’d be interested to hear.