Subscribe via FeedMatt White, Apr 10, 2012 9:23:46 AM
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.
5 responses to Using document data in a page title
homeopathie, October 6, 2009 10:14 AM
Hello
I have read all information which you have given and it is really very useful for me.Thank you for sharing this solution with us.This information will be helpful for those who gets problem like you.
Darin Dutcher, October 5, 2009 1:39 PM
You posted just as I was. You are right I had the same problems, when trying to set the page title from the custom control.
Darin Dutcher, October 5, 2009 1:37 PM
document1.getItemValueString("PageName") is what I use on the xpage properties.
Matt White, October 5, 2009 1:35 PM
@Steve, I wasn't able to set the pagetitle property the custom control or the XPage itself. I agree that this feels like a bug, but it's not an especially serious one. I had assumed that your suggestion would work but it doesn't hence the reason for this post in the first place. :-)
Steve Castledine, October 5, 2009 9:45 AM
My memory is failing me here, but I think this is more bug than feature. I may be confusing with something else, but for some reason setting the title within the custom control does not bubble up, however if you set the title within the xpage that contains the custom control it should work.
ie if your data source is called say document1 - and your data is within a custom control - just setting the title property within the main xpage using say document1.getItemValueString("subject") should work?