Quick tip: updating URL hashes in XPages

I’m a big fan of the ExtLib Dynamic Content control. Use it in probably all my single-page XPage apps. Recently I was working on a page that had 2 nested Dynamic Content controls. I wanted to allow users to bookmark the page, including the state of both controls. I wanted to use a URL hash to do that. The useHash option apparently only supports one level, so I had to write a solution involving some client side JavaScript to update the URL hash. Here’s what I used to access the URL hash and update it:

//get the current hash value as a JavaScript object
var hash = dojo.queryToObject( dojo.hash() );

//add a parameter
hash['newParam'] = newValue;

//update the hash
dojo.hash( dojo.objectToQuery(hash) );

3 thoughts to “Quick tip: updating URL hashes in XPages”

  1. Hello Mark Leusink,

    i’ve read your post but do not understand how do you solve your issue exactly.
    I’m just working with dynamic Content and “useHash”.
    Do you have implemented your code. On onclientload?

  2. If you have only one level of tabs then the ‘useHash’ property will work just fine.

    I’m using this technique in a layout with multiple nested tab sets. When a user clicks on a nested tab, I call dynamicContent.show(‘xx’) to show the correct content. Using clientside JavaScript I then add the correct style to the tab that was clicked (and remove the ‘active’ class from the other tabs). I then (also in clientside JavaScript) use the method I described to update the URL hash. That way the user can bookmark the page and when he returns, it can open the correct (nested) tab.

Comments are closed.