Navigating XPages: Where Next?

Home » Navigating XPages: Where Next?

I’m currently working on an XPages app after a few months back on client development. So there’s a bit of trying to remember how to do things, and also some pondering about improving practice. One of these areas was on navigation.

Historically, my buttons have included event code that finishes by sending the user to a specific page, using context.redirectToPage() or the Open Page simple action. For my new app I wanted standard form buttons, so started hunting around for a better way to redirect the user. My first port of call (sorry, couldn’t resist the navigational joke!) was the Properties of the button, and I found my Cancel button created an xp:eventHandler which had a property “navigate”. The value can be true or false, and the comment is this:

Action used to navigate to another page

Great, I thought, but how to I specify what my other page will be? Sorry, I still haven’t got the answer to that one.

But I then looked at the XPage and thought “There must be something there that specifies the next page”. In the tabs on the Properties panel I saw Navigation, for specifying Navigation rules. More on that shortly. But the obvious answer, as probably all of you know, is on the XPage tab, the “Next page (success or cancel)” and “Next page (if update fails)”.

XPage tab

A very useful option here is Previous Page, which does exactly what it says on the tin.

But what if you want to go to one page on cancel but another page on success? This is where Navigation rules come in. One or more navigation rules can be added, with an alias and a location.

Navigation rules

For a little while I wondered how you use the alias, but a jsp post on the 8.5 forum pointed me in the right direction. The alias is the action of e.g. a button. So a Cancel button may have code that does return “cancel” (a string value). This picks up a navigation rule on the XPage and so knows where to route the user. This is a very useful and quite simple method for navigating, even if you have extremely complex alternatives.

Button code

 

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top