This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal



Aug 25, 2011, 5:44 PM
37 Posts
topic has been resolvedResolved

Allowing users to select themes

  • Category: Styles and Themes
  • Platform: Windows
  • Release: 8.5.2
  • Role: Developer
  • Tags: themes
  • Replies: 3
Hello!
 
I'm a longtime Notes/Domino developer, however, somewhat new to XPages.  In traditional Domino apps, it was easy to program several style sheets, and allow users to select a CSS and store a cookie with that value.  This way, when that user goes on one app (or many apps), the same CSS will be read.
 
Is it possible to change a theme "on the fly" like this?
 
Thanks, in advance!
 
Steve in NYC
 
"It hurts to be on the cutting edge."
Aug 26, 2011, 8:17 AM
261 Posts
Re: Allowing users to select themes
Hi Steve,
 
What I'd do in your case is to create a single theme-definition in which all your different stylesheets are listed as resources. Next you add a rendered attribute to the stylesheet resources to conditionally include them (based on a sessionScope variable for instance). The code in a theme would look something like this:
 
    <resource rendered="#{javascript:sessionScope.get('theme')=='gold'}">
        <content-type>text/css</content-type>
        <href>/.ibmxspres/domino/oneuiv2/goldTheme/goldTheme.css</href>
    </resource>
 
Mark
Sep 1, 2011, 8:34 AM
7 Posts
Re: Allowing users to select themes
 Steve,
You can change themes programmatically:  context.setSessionProperty("xsp.theme","newTheme");
 
I usually place a theme switcher in the user menu, which is built with <xp:link> 's
You need to reload the page in order to apply the new theme:
 
var currentPage = "/"+@RightBack(context.getUrl().getAddress(),"/");
context.setSessionProperty("xsp.theme","newTheme");
context.redirectToPage(currentPage); 
 

Sep 1, 2011, 7:22 PM
37 Posts
Re: Allowing users to select themes
Thanks!
 
   I saw an example like this on the wiki, so I'll give it a shot.
 
Cheers!
 
Steve in NYC

This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal