This, that and the other (may contain nuts)

Simple XPages Theme Tip

Steve Castledine  18 December 2009 11:56:34
There was a question "how do I allocate a particular theme to a particular XPage?", this is because in general the theme set is for the entire nsf and changing it for one XPage means changing it for all (via the application properties).

However if you think about this differently, and almost as an extension to the XPage itself when it builds its header information, you will see that one theme does not mean fixed settings for all as the power of the theme is about computation via the rendered attribute.

So instead of trying to use multiple theme's and coding the actual theme change via back-end code and reloading the page, just compute everything in the theme itself. For example if we had a red.xsp and a blue.xsp and they needed different style sheets because of their different colour requirements we can compute the delivery of these style sheets from one theme as:

<resource rendered="#{javascript:facesContext.getViewRoot().getViewId().equals('/blue')}">
        <content-type>text/css</content-type>
        <href>blue.css</href>
</resource>
<resource rendered="#{javascript:facesContext.getViewRoot().getViewId().equals('/red')}">
        <content-type>text/css</content-type>
        <href>red.css</href>
</resource>