Search
Categories

Entries in page title (1)

Tuesday
06Oct2009

Using document data in a page title

One little thing which had been bugging me for a while (though not quite enough for me to spend any time looking at it until now!) was how to set the page title of an XPage to use some value from a document data binding.

First of all, why is it important to do this? Well if your site is on the internet then the <title> tag is very important from the Google search side of things, so you want to have useful information in there. And from the user's point of view, with many browser tabs open it's useful to have a detailed title to help with finding the right window.

The problem is that I have a custom control inside my XPage that has all of the data binding, and by the time the document binding has happened so that I can get the page title from it, the pageTitle property of the XPage has already been computed, so I end up with no title at all.

It really just took 15 minutes of digging around in two areas, finding the object that contains the page title property that we can manually set, and the event that runs late enough that we can get the data from the document, but early enough that the HTML has not yet been rendered to the browser.

So, here is my solution...


In the postOpenDocument event of the document data binding we know that we have the document in memory so we can refer to it (using a getItemValueString in this case), and then the view object offers us the setPageTitle method where we can insert whatever string we want into the page title.

A simple tip, but maybe not so obvious if you're having trouble with the Page Title setting in All Properties.