2
votes

Based on this snippet (http://openntf.org/XSnippets.nsf/snippet.xsp?id=oneui-on-the-fly-theme-changer) I tried to calculate the theme depending on the release of Domino. I'd like to use "oneuiv2.1" on Domino<9 and "oneuiv3.0.2" on a 9 release.

EDIT: To be clear: I already can identify the version, the question is about calculating and setting the theme at the right time as my following approaches seem to do the work too late. The page renders and then the theme is set - however this is my impression.

These were my first approaches:

  1. Calculate the theme name in the "extends" property of the theme - didn't work.
  2. Calculate and set the value of the session property "xsp.theme" in a beforeRenderResponse and beforePageLoad event of my Xpage - this also failed
  3. Set up a bean to calculate the value and set the session property when the bean is initialized - same result

Of cause you can calculate (render) all the needed stylesheets and scripts of OneUIv2.1 and OneUIv3 in the theme file but hey, this is quite a hassle with that amount of resources, isn't it?

So my question is: do you have any other ideas how to achieve this? This would be very handy to use if your applications can use both themes with the same layout, independent where the application runs - whether on a 8.5.x or 9 machine.

Looking forward to the discussion :-)

2
I had success with the context.setSessionProperty("xsp.theme",theme); method, but only if I redirected the user to the same page again after setting it using context.redirectToPage(<calculate current page here>);Mark Leusink
That's it Mark! Thank you!Oliver Busse

2 Answers

3
votes

You can change theme on beforePageLoad event:

<xp:view xmlns:xp="http://www.ibm.com/xsp/core"
    beforePageLoad='#{javascript:
        var theme = session.getNotesVersion().startsWith("Release 8") ? "oneuiv2.1" : "oneuiv3.0.2";
        if ( ! theme.equals(context.getSessionProperty("xsp.theme"))) {
            context.setSessionProperty("xsp.theme", theme);
            context.redirectToPage(context.getUrl().toSiteRelativeString(context));
        }
    }'>

The trick is to set session property "xsp.theme" and to redirect to same page if theme has to be changed.

redirectToPage() will happen only one time per session as Notes version won't change during session.

0
votes

If you use Extension Library you can do this to look for the version of Domino:

@Left(com.ibm.xsp.extlib.util.ExtLibUtil.getExtLibVersion(), 3) == "8.5")