getFragment() Doesn’t

The XSPUrl object that you can access via the XPages context has a lot of handy methods. getFragement() isn’t one of them.

I was looking through the help documentation for XSPUrl recently and noticed that the object includes a method for getting the url fragment (i.e. the part of the URL after the hash). It was unexpected, but I figured it could be handy since I was working with some (non-XPages) tabs on pages in a recent application.

However, as shown on Dave Leedy’s helpful XPages URL Cheatsheet, getFragment() doesn’t return anything when referring to the URL gleaned from the current context!

This makes sense, as the hash is a client-side redirect and is not even sent to the server, so a server-side method wouldn’t be able to see it. But it’s included in the XPages Documentation which, hilariously, references Chris Toohey’s post about this from several years ago.

Fortunately, if you need to work with the hash, you can use client-side Javascript’s location.hash property and pass it to server-side code as needed.



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: