Your Development & Design Resource

XPages, Session Scope Variables, and User Agents in IBM Lotus Notes Domino Application Development

I've talked before about progressive enhancement in the context of application development and supporting multiple User Agents - be they the Lotus Notes Client, various Web Browser Clients, or even Mobile Devices like the iPhone, iPad, and BlackBerry! The idea is simple enough -- render unto the User Agent what works for that particular User Agent.


This tutorial is designed for novice / beginner level XPage application developers, and these techniques can be used in Lotus Notes Client, Web Browser Client, and Mobile Device Client IBM Lotus Notes Domino Application Development.


This tutorial will walk you through creating an XPage that uses a Scoped Variable and returns that value -- the current User Agent -- to the UI.

I will follow-up this post with a more advanced use of this technique, specifically using the User Agent Session Scoped Variable to control the rendered content for an XPage application.

When & Where?

You will eventually use this technique to conditionally display XPage Controls. Consider, if you will, that each Control is a Subform on a Form Design Element.. The rendered parameter allows us to define conditions for when the given XPage Control is displayed... not until a Computed Subform on a Form Design Element. Unlike a Computed Subform, the rendered logic, there is a minimal performance hit when using multiple rendered Controls on an XPage.

This gives us the ability to write a single Design Element to address multiple Client Types while simplifying overall development maintenance.


Using this technique, you can choose to render the iWebKit Framework for WebKit-based User Agents (iPhones, iPads, BlackBerry OS 6 devices, Palm Pre, etc.) or BlackBerry OS 5 (or less) -friendly markup as needed.

You can provide specific User Agents with device/client-specific features and functionality, and with Session Scoped Variables, the "cost" of calculating the logic can be greatly reduced!

The Build

Going really simple here: I'm going to create the Scoped Variable UA that stores the text value of the User-Agent Header. I'll then use that Scoped Variable in the UI of my XPage.

First, the XPage Source:

<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp=""
    pageTitle="Agent Smith Says...">

        <xp:styleSheet href="/style.css"></xp:styleSheet>

            var exCon = facesContext.getExternalContext();
            var request:HttpServletRequest = exCon.getRequest();
            var UA = request.getHeader("User-Agent");

    <span id="useragent_content">
        We've had our eye on you for some time now, Mr.
        <xp:text id="useragent" value="#{sessionScope.UA}"


I am defining my Session Scoped Variable UA in the XPage afterPageLoad Event.

I am then using the sessionScope.UA in my ComputedText Control to return in the XPage UI the current User Agent.


With a little CSS and an Image Resource...

Smith Says: IBM Lotus Notes Domino XPages App Demo

Now, this is a simple example, but after defining the Session Scoped Variable UA, I am able to use it in any context within my XPage application while within that session.

Example / Demo Download

Agent Smith Says... IBM Lotus Notes Domino XPage 
Application Example / Demo Download

This application can be used in the Lotus Notes Client as well as in a Web Browser Client. Technically, it could be used in a Mobile Device Browser Client, but the 450x500 image of Agent Smith might not work unless you're running a device with a high-res screen.


I'll be using this very simply technique in follow-up posts to show you how the defining rendered Controls on the User Agent will allow you to create some really slick IBM Lotus Notes Domino XPage Applications.

If you have any questions -- or requests -- comment to this post or contact me at

About the author: Chris Toohey

Thought Leadership, Web & Mobile Application Development, Solutions Integration, Technical Writing & Mentoring

A published developer and webmaster of, Chris Toohey specializes in platform application development, solutions integration, and evangelism of platform capabilities and best practices.

More from is powered by IBM Notes Domino XPages & hosted by Prominic.NET

Contact Us

Use our Contact / Feedback form or one of these email addresses:

Creative Commons License

Except where otherwise noted, by Chris Toohey is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.