In Xpages resource files can be used to store settings. This is a great way of increasing the configurability of your application ( labels, keyword choices etc ) without having to carry the overhead of frequent look-ups to Notes configuration documents. This approach is a core part of the Steve Castledines OpenNTF Xpages Framework and has also been recommended by Matt White.
This article describes how to create a resource file via DXL using a stream so that an intermediate file on the hard drive is not needed. The code incorporates other code from Julian Robichaux for managing the Base64 encoding.
Entering the configuration
The application has a series of configuration documents. As each is saved in the UI it calls a back end LotusScript agent which creates a file resource. The Xpage application pulls the settings directly from this file resource rather than from the documents themselves.
The system does not attempt to update the file resource but creates a new one from scratch by cycling though the view and adding information for each record.
The structure of the file resource
Retrieving the settings
The settings can be retrieved using the code below, note that you also need to include the file as a resource bundle
The code to create the resource file
The crux to creating the file resource is that it is in base64 so you will need to use some code originally developed by Julian Robichaux and published on OpenNTF
I have attached the whole script library at the end of the article. The entry point called by the agent is Sub s_CreateFileResourceFromView_6_01
I have posted the code as an attachment. Apologies for not including a demo database but I would need to strip the functionality out of a commercial system. The attached code has plenty of commenting .
This article has also been posted on the IBM Developers Wiki