Get all available language resource files for language selection

February 15, 2013 – 8:49 am

Assume you have built a multi language XPage application and want to add a language switcher to the application. The content for the selector should be build automatically when you add a new language resource to the application.

I store my language resource files in the files section of Domino Designer. Each file has a file suffix of “”


To get a list of all files with this specific suffix I put together some Java. The code builds a NoteCollection of MiscFormatElements and then does a serach within the collection to return only elements that match the search criteria.

package de.eknori;
import java.util.Vector;
import javax.faces.context.FacesContext;
import lotus.domino.Database;
import lotus.domino.Document;
import lotus.domino.NoteCollection;
import lotus.domino.NotesException;
public class Design {
	private static final String SUFFIX_PROPERTY = "";
	private static final String EMPTY_STRING = "";
	private static final String FIELD_TITLE = "$TITLE";
	public static Vector getLangFiles() throws NotesException {
		Vector vec = new Vector();
		try {
			FacesContext fc = FacesContext.getCurrentInstance();
			Database db = (Database) fc.getApplication().getVariableResolver()
			.resolveVariable(fc, "database");
			NoteCollection nc = null;
			nc = db.createNoteCollection(false);
			nc.setSelectionFormula("@Contains(" + FIELD_TITLE + ";\""
					+ SUFFIX_PROPERTY + "\")");
			String nid = EMPTY_STRING;
			nid = nc.getFirstNoteID();
			Document doc = null;
			while (!(EMPTY_STRING.equals(nid))) {
				doc = db.getDocumentByID(nid);
				nid = nc.getNextNoteID(nid);
		} catch (Exception e) {
		return vec;

In your XPage, you can then simply make a call to the method from a combobox

< ?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="">
	<xp:label value="Select Language: " id="lblSelLanguage" for="cmbSelLanguage"></xp:label>
	<xp:combobox id="cmbSelLanguage">
		<xp:selectitems value="#{javascript:new de.eknori.Design.getLangFiles()}"></xp:selectitems>

And here is the result


And with just a little tweak you can use the code to get a list of available themes and build a theme switcher …  Happy coding!

Sorry, comments for this entry are closed at this time.