One of the initially most frustrating things about XPages was that, unlike in standard Notes, if the user closed a window without saving, it never warned them. If you expect to be warned and never are, you’re bound to lose some data and be frustrated.
Fortunately, you can design your application to pay attention to whether the user has “dirtied” the page by editing it, even identifying down to specific input elements of which you care or don’t care about the “dirtyness”. I can’t explain why they wouldn’t have made it the default behavior, since it is the default behavior in Notes, but they did.
In the original edition of Mastering XPages, I got out to around page 300 before specific work inhibited me from further page-by-page progress, so I never got to read Chapter 13, on XPages in the Notes Client (XPiNC). I’m very surprised, since most of my work now needs to run XPiNC.
So, the key to making your custom controls and XPages being “cleanliness-aware” is to set the enableModifiedFlag = “true“. This allows the system to keep track of whether something within that element has been dirtied by the user and, if so, complain when the user tries to navigate away. You can even create a custom message for the user and specify a control to execute if the user clicks OK.
Now, the unfortunate thing is that the only containers that this flag works on are the big ones – the XPage or the custom control. I’d really like to be able to use it on a panel or table or some smaller element, so I can package my concern for ‘cleanliness’ in slightly more granular ways.
Fortunately, they also allow you to use the disableModifiedFlag on specific core controls. It is really important to note that the enableModifiedFlag takes precedence, so you cannot use disableModifiedFlag=”false” to get your notice if you didn’t enable it on the custom control or XPage.
The following Core Controls support this feature:
- Edit Box
- Multiline Edit Box
- List Box
- Combo Box
- Check Box
- Radio Button
- File Upload
- Date Time Picker
- Rich Text Editor
Again, this is a property I’d like to see on other containers so that I can use fewer properties to granularize my cleanliness monitoring (and maybe save minor bits of memory and bandwidth?).
Not everything that you would consider “navigating away from the page” gets treated by XPages. I’m not sure of everything that it ignores, but I do know that when we had navigation using the simple action openPage, the system never warned me that I was navigating away from the page – browser or XPiNC. Fortunately, I was able to discard the simple actions that were running in that link and just have it use the URL for the XPage I wanted to navigate to, allowing notification of dirtyness,
This method did not work:
<xp:link text="All inventory" escape="true" id="inventoryLink" target="_self" value="/inv_allInventory_view.xsp"> </xp:link>
Pingback: Dirty pages and keeping users on them in #XPages | Lost in XPages, Soon to be Found