Managed properties

For an application we aggregate the data from several servers and databases. In SSJS applications I tend to save such properties in Notes configuration documents and store them in scoped Variables during initialization. Something like was provided in the XPages Framework a while ago.

In episode 182 of Notes in 9 David Leedy gives a great demonstration how to work with Notes documents via Managed Beans. However for properties that should not be altered likely by an application administrator (could be the application owner, a regular Notes user) I tend to work with managed properties. With managed properties you more or less configure your managed bean.

So how could this look like?

In the faces-config.xml I set the properties for a managed bean e.g.

<?xml version=”1.0″ encoding=”UTF-8″?>



which I can use then in my java code:

package com.wordpress.quintessens;
public class ConfigBean implements Serializable {
private String dataSource;
//… more variable declarations

public JsonJavaObject loadBackEndConfig(String Key) throws NotesException {
JsonJavaObject json = null;
NotesContext nct = NotesContext.getCurrent();
Session session = nct.getCurrentSession();
String DatabaseName = session.getCurrentDatabase().getFilePath();
String ViewName = “(LookUpBackEndConfig)”;
try {
json = loadJSONObject(this.dataSource, DatabaseName, ViewName, Key, 1);
} catch (NotesException e) {
// TODO Auto-generated catch block
return json;

public void setDataSource(String dataSource{
this.dataSource = dataSource
public String getDataSource() {
return dataSource


You can check if the value is passed correctly e.g. via Expression Language:

<xp:text escape=”true” id=”computedField1″

I am curious how you prefer to configure your applications? In some cases I find it perhaps an overkill to store the configuration in Notes documents and publish the values via a managed bean.

Happy development =)


new release XPages OpenLog Logger and custom runtime error page


Good news for me! In an XPage application I wanted to provide an error logging function and preferably to OpenLog. I had problems with implementing the previous version of OpenLog logger but yesterday a new version is released on OpenNTF which took away that pain.

OpenLog logger

The OpenLog logger has some powerful features:

  • It can be used in your managed beans and other Java classes.
  • It can be used directly from SSJS with as little as openLogBean.addError(e,this);.
  • From SSJS all caught errors on the page are logged out together, at the end of the request.
  • Only two method names are used from SSJS, one to add an error, one to add an event, making it easy to pick up
  • From SSJS you only need to pass the information you wish. There is no need to pass nulls or empty strings.
  • From SSJS only one unique error per component is logged, regardless of how many times the error is encountered during the refresh lifecycle.
  • In SSJS, if you use a custom error page, uncaught errors will also be logged.
  • Uncaught errors will be logged for the page the error occurs on, not your custom error page.
  • You can define the OpenLog path and a variety of other variables without needing to change the code.
  • The functionality and code are available as an OSGi plugin (the best practice approach) but can also be included in individual NSFs.

Custom Runtime Error Page

In case you want to implement such functionality then I recommend you also take a look at how to define a custom run time error page. In my project I am using Bootstrap for UI look & feel, so I followed the steps Erick McCormick provides in this blog post.


In Erick’s post you will find that he uses Google’s code-prettify project. A nice feature is to ability to set a skin for the error message box. There are plenty of color themes available for the prettify project but if you use Bootstrap like I do you could try this theme.

A big thank you to the OpenLog logger project members and Erick!



Infinite scroll and prevent multiple event fire

Probably a lot of you use the “Simple custom control to add infinite scrolling to repeat or views” available as codesnippet on OpenNTF.

This snippet allows you to load a next set of documents for a repeat or view control when you reach the bottom of the page. A feature that will be appreciated highly by mobile users of your Notes app.

If you look at the code, it fires the click event of a pagerAddRows control when you have reached the bottom of the window. This will happen as long as you are on the bottom of the window. What can this cause for disturbance:

  • It fires multiple events, while it is at the bottom of the window. You only asked for 1.
  • The events are not chained so when the second event is returned quicker that the first it will be inserted before it, which messes up the sorting of your collection.

I have not found a way to create a JS function to load a set of data from a repeat control in the ajax way. That would allow you to use the success property and set a state (ajaxready, true/false) for your window. This state could be used to check if the fire event is entitled to run or not.

Drop a line in cause you know the answer to such a function.

As a temporarily solution I suggest to keep the click event for the pagerAddRows control but set a timeout.

Here is what the code could look like:

<xp:scriptBlock id=”scriptBlock1″>
<![CDATA[$(window).data(‘ajaxready’, true).scroll(function(e) {
if ($(window).data(‘ajaxready’) == false) return;
if ($(window).scrollTop() >= ($(document).height() – $(window).height())) {
$(window).data(‘ajaxready’, false);
setTimeout(function() {
$(“.infiniteScroll ul li a”).click();
dojo.query(“.timeago”).forEach( function(el) {
var timeagoWidget= dijit.getEnclosingWidget(el);
timeagoWidget = new timeago.Timeago({}, el);

//refresh timeago
$(window).data(‘ajaxready’, true);
}, 200);


Here is set a timeout for 200 milliseconds which turns out to be quiet generous in my application, but at least I have prevented the disturbances mentioned earlier.

Happy coding!

collapsible menu with persistent state


For a project I needed to have collapsible menus where the state is persistent, in other words after a refresh or a reload it should now if the menu was opened or closed.

The content of the menu is dynamic and rather complicated containing sub levels with multiple actions in them. Each level item would trigger to rebuild the presented document collection via Java (perhaps more common known as a faceted search).


Since we are using the Extension Library I took a look at the controls but I could not find one that fulfills my requirements (accordion, dojo accordion pane, dojo tab pane, outline). To prevent to embed “another” Jquery plugin I looked across the Dojo site and found the titlePane dijit.

A TitlePane is a pane that can be opened or collapsed, with a title on top. The visibility of the pane’s contents is toggled by activating an arrow “button” on the title bar via the mouse or keyboard. It extends ContentPane but since it isn’t used inside other layout widgets it’s not in the dijit.layout module.

To be honest I am not a Dojo warrior and mostly are satisfied with jQuery plugins but this sounded like something that I could use. For now I only have to menu sections to collapse; a KPI section and a Filter section. Each section has there level 1 and level 2 items.

Since the application works as much as possible with partial refresh and each filtering affects the content of these 2 sections I also needed to save the state of the panes (open or closed). This sounded like a combination of client (open / close the pane) and server side (save the state in a scope variable) actions. Hmmm. From day 1 I have found this mixture of CSJS and SSJS a problem child which you tend to forget/mess up. I decided to implement the approach Oliver Busse promotes in the following post “Writing and reading scoped variables via client side Javascript“. This approach probably makes the code less cluttered with mixture of languages.

I also noticed that the titlePane dijit is not error-proof implemented in the Bootstrap4XPages project in the Extension Library but I found a fix described in the post “fix for down caret icon in dijit.TitlePane when using Bootstrap from ExtLib“. I got a response from Brian Gleeson (IBM): A fix for the dijit.TitlePane issue has been delivered, and should show up in the next Extension Library release. Great & thank you Brian!

So having conquered the circumstances described above what became the result and how did I implement it?


Let’s start with the result:


Image 1: first section opened.


Image 2: both sections opened.


Each of the KPI and Filter item (can) have sub levels with different presentation and functionality which I will not describe for simplicity reasons.


The titlePane dijit is not so hard to implement. Add the dojo module to your resources:

<xp:dojoModule name=”dijit.TitlePane”></xp:dojoModule>

Next add a div to your XPage and set the dojoType and title property. The mat-card styleclass provides a material design presentation.


Also define custom attributes for open and toggleble for the div element. These are properties of the titlepane dijit.

Event handler

The event handler checks the state of the pane and writes the state to a scoped variable when the title section of the pane is clicked. For a complete description how to implement Oliver Busse’s utility I would like to direct you to his site.

id=”titlePaneKPI”  dojoType=”dijit.TitlePane” title=”Sales KPI”  styleClass=”mat-card”>
<xp:attr name=”open” value=”false”></xp:attr>
<xp:attr name=”toggleable” value=”true”></xp:attr>
<xp:eventHandler event=”onclick” submit=”false”>
<xp:this.script><![CDATA[var KPI = dojo.dijit.byId(“#{id:titlePaneKPI}”);
if ({
setScopeValue(“view”, “MenuKPI”, “1”);
setScopeValue(“view”, “MenuKPI”, “0”);

</xp:div><!– /dijit.TitlePane –>

Odd behaviour

I also noticed a strange behaviour of the titlePane. At start I had multiple controls on my xpage to see their differences and capabilities. When I removed the Dojo Accordion Pane the carets for the dijitPane behaved odd:


Note the plus (+) and minus (-) signs after the caret :-?

So in front of the TitlePane dijit divs I placed a Dojo Accordion Pane and set the display style property to none (via a styleclass):

<xe:djAccordionPane id=”djAccordionPane1″


titlePane content

The content of the titlepane can be anything, in my case via a repeat controls a list group with list-group-items is generated.

  • Lead Flow

    <!– /col-xs-12 col-sm-12 col-md-12 col-lg-12 –>
    </div><!– /row –>

    Qualified Opportunities

    <!–/col-xs-12 col-sm-12 col-md-12 col-lg-12 –>
    </div><!– /row –>


  • Personally I find it a good practice to comment the closure of elements, especially when using Bootstrap nowadays.

    Event handler when loading the page/custom control

    The last thing to include is an event handler that opens or closes the titlePane dijits depending on their last states that are stored in scoped variables.

    I placed the event handler on the custom control where the titlepanes reside in so it gets initiated every time a partial refresh takes place for the custom control.

    <xp:eventHandler event=”onClientLoad” submit=”false”>
    <xp:this.script><![CDATA[function getMenuState(){
    var KPI = dojo.byId(“#{id:titlePaneKPI}”);
    var Filter = dojo.byId(“#{id:titlePaneFilter}”);
    var KPI_status = getScopeValue(“view”, “MenuKPI”);
    var Filter_status = getScopeValue(“view”, “MenuFilter”);

    I was not able to store the function in a CSJS library because it kept telling me then that dojo could not find any note to act upon, but this is probably due to my lack of guru knowledge of Dojo.

    Wrap up

    That is about it! With little programming and a couple of hordes I managed to apply a menu with a consistent state when performing partial refreshes!

    I am looking forward to hear what alternative solutions you have produced, perhaps they can serve me in the future. Happy coding!


    fix for down caret icon in dijit.TitlePane when using Bootstrap from ExtLib

    For unknown reason the dijit.TitlePane is not part of the Dojo controls in the ExtLib. You can implement your own version and Mark Roden posted a nice description how to achieve this. HOWEVER in case you are using the Bootstrap theme in the Extension Library you will notice when opening a pane the down caret icon can not be displayed.

    Here is the build up for 2 TitlePanes dijits:

    <xp:div id=”titlePaneGemCars” dojoType=”dijit.TitlePane” title=”German Cars”>
    <xp:attr name=”open” value=”false”></xp:attr>
    <xp:attr name=”toggleable” value=”true”></xp:attr>
    <xp:div id=”titlePaneJapBikes” dojoType=”dijit.TitlePane”
    title=”Japanese Bikes”>
    <xp:attr name=”open” value=”false”></xp:attr>
    <xp:attr name=”toggleable” value=”true”></xp:attr>

    Here is how it looks like in the browser:


    In case you choose another theme e.g. oneUI (*cough*) the panes are displayed as followed:


    Note the display of carets is different (no carets for closed panes).

    So how are we going to fix this? Via your friend CSS! Include the following CSS snippet at your page/stylesheet/theme:

    .xsp.dbootstrap .dijitTitlePane .dijitArrowNode::before {
    color: #428bca;
    font-family: “Glyphicons Halflings”;
    content: “\e114”;
    font-size: 12px;
    padding-left: 10px;
    position: relative;
    top: -1px;

    The definition is similar for a closed dijit but the content is set here to specific Glyphicon (the chevron down icon). The content is set to a hexidecimal value for an icon? On the glyphicons site you can search for halflings and it will tell for the chevron-down icon the value is UTF+e114.

    As a result your opened titlepane wil have the correct icon displayed:


    Happy coding!

    Ps I assume there is someone smart here to register this break as a request at IBM?

    context.getProperty(‘xsp.resources.aggregate’).equals(‘…’) working for resource and not resources definition

    In a previous post I described a problem when implementing Font Awesome in conjunction with the Use runtime optimized JavaScript and CSS resources XSP property. The solution can be summarized as followed:

    • – Move the @font-face part in the font-awesome.min.css into 2 new CSS e.g.


    • adapt for minified version the paths to the fonts e.g.


    • load in a Theme design element the correct version based upon your XSP property setting:

    context.getProperty(‘xsp.resources.aggregate’).equals(‘…’)   //true or false

    This works for a resource definition but apparently not for a resourceS definition.

    The following code

    <resources rendered=”#{javascript:context.getProperty(‘xsp.resources.aggregate’).equals(‘false’)}”>
    <resources rendered=”#{javascript:context.getProperty(‘xsp.resources.aggregate’).equals(‘true’)}”>

    will load both files in optimized / non optimized runtime. Perhaps IBM can fix this?

    Working with JSON in your XPages application (3) – getEntriesByKey


    In our third example we will extend the loadPictures method in the first blog entry in this serie to detect whether or not we want to load just all the entries in a view or entries that match a key in the first sorted column.

    Use case

    In the following simple scenario a user makes an selection (e.g. from a combobox) and corresponding picture documents will be displayed, as in the image:


    Whenever a different value is selected the list with corresponding documents will be updated.

    So how do we do this?

    Switch between Notes views

    The main difference is the key send if we do or don’t (empty value) want a filtering of the result list. To collect this key we provide a combobox:


    The loadCategories method provides an ArrayList of String values:

    public ArrayList<String> loadCategories(String ViewName) throws NotesException{
    System.out.println(appRef + “.loadCategories()”);

    NotesContext nct = NotesContext.getCurrent();
    Session session = nct.getCurrentSession();

    String ServerName = “dev1”;
    String DatabaseName = session.getCurrentDatabase().getFilePath();
    Database DB = session.getDatabase(ServerName, DatabaseName);

    View luView = DB.getView(ViewName);
    ViewNavigator vwnav = null;
    ViewEntry vwentry = null;
    ViewEntry vwentrytmp = null;

    // all results will be added to this
    ArrayList<String> categories = new ArrayList<String>();

    // disable autoupdate

    vwnav = luView.createViewNav();

    // setting buffer for fast view retrieval

    // perform lookup
    vwentry = vwnav.getFirst();
    while (vwentry != null){

    // Get entry and go recycle
    vwentrytmp = vwnav.getNext(vwentry);
    vwentry = vwentrytmp;

    return categories;

    The xp:Combobox control is bound to a viewScope variable and it’s onChange event triggers a partial refresh on a panel:

    <xp:panel id=”pictures”>
    <xp:pager layout=”Previous Group Next” partialRefresh=”true” id=”pager1″ for=”repeat1″></xp:pager>
    <table class=”table table-hover”>
    <xp:repeat id=”repeat1″ rows=”15″ var=”pix”>

    <xp:this.value><![CDATA[#{javascript:var active = viewScope.get(“activeCategory”);
    if (active == “All”){
    <xp:text escape=”false”>
    getAttachmentURL and getBaseURL from:

    function getAttachmentURL(docID:java.lang.String, attachmentName:java.lang.String) {
    var base = getBaseURL();
    var middle = “/xsp/.ibmmodres/domino/OpenAttachment”;
    if (base.substr(0,4) == “/xsp”) {
    middle += base.substr(4);
    } else {
    middle += base;
    var result = base + middle + “/” + docID + “/$File/” + attachmentName + “?Open”;
    return result;

    function getBaseURL() {
    var curURL = context.getUrl();
    var curAdr = curURL.getAddress();
    var rel = curURL.getSiteRelativeAddress(context);
    var step1 = curAdr.substr(0,curAdr.indexOf(rel));

    // Now cut off the http
    var step2 = step1.substr(step1.indexOf(“//”)+2);
    var result = step2.substr(step2.indexOf(“/”));
    return result;
    var thumb = pix.imgthumb;
    var id = pix.docUNID;

    return “<img src='” + getAttachmentURL(id, thumb) + “‘>”;
    <td><xp:text escape=”true” value=”#{pix.subject}”></xp:text></td>
    <td><xp:text escape=”true” value=”#{pix.category}”></xp:text></td>
    <td><xp:text escape=”true” value=”#{pix.descr}”></xp:text></td>
    <td><xp:text escape=”true” value=”#{}”></xp:text>
    </tr><!– /.row –>


    Depending on the value in the viewScope we call the loadPictures method empty or with a key.

    private ArrayList<JsonJavaObject> loadJSONObjects(String ServerName, String DatabaseName, String ViewName, String Key, Integer ColIdx) throws NotesException {
    ArrayList<JsonJavaObject> JSONObjects = new ArrayList<JsonJavaObject>();

    NotesContext nct = NotesContext.getCurrent();
    Session session = nct.getCurrentSession();
    Database DB = session.getDatabase(ServerName, DatabaseName);

    if (!(DB==null)) {
    View luView = DB.getView(ViewName);

    if (!(luView == null)) {
    JsonJavaFactory factory = JsonJavaFactory.instanceEx;

    ViewEntryCollection vec = luView.getAllEntriesByKey(Key, true);

    ViewEntry entry = vec.getFirstEntry();
    while (entry != null) {

    Vector<?> columnValues = entry.getColumnValues();
    String colJson = String.valueOf(columnValues.get(ColIdx));
    JsonJavaObject json = null;

    try {
    json = (JsonJavaObject) JsonParser.fromJson(factory, colJson);
    if (json != null) {

    } catch (JsonException e) {
    // TODO:

    ViewEntry tempEntry = entry;
    entry = vec.getNextEntry();
    return JSONObjects;

    Similar as in the previous examples the JsonJavaObject class from the package is used to return an arraylist of json objects.

    In the next post I will describe how we can manipulate the JSON objects.