Fredrik Norling blogged yesterday about using Regular Expressions to validate in XPages (but also traditional Domino web development). There is one option for validating using regular expressions that Fredrik didn’t mention, and it’s well worth covering. Because although you can find a lot of regular expressions on the web, writing your own or modifying regular expressions can be challenging. And testing the regular expressions can be a slow and boring process. Wouldn’t it be great if you had a wizard to build them in Domino Designer? Wouldn’t it be great if you could test them from within Domino Designer?
Well, actually you can, thanks to those nice developers at IBM.
If you want to validate and throw errors client-side, you might want to use the Dojo Validation Text Box. If not, it’s still worth dropping a Dojo Validation Text Box on your XPage, just to be able to play about with and test your regular expressions in Designer. The Dojo Validation Text Box has a property called regExp. You can manually type the regular expression in, as with the validators. But things get really interesting when you launch the external property editor.
That first tab allows you to build up your regular expressions. You can select from predefined tokens such as “Any character”, “Alphanumeric character”, “Lower case”, then define the number of occurrences. The Add button allows you to build up a regular expression.
And if you find a regular expression online that you think is what you need, you can just type it into the “Current regular expression” box.
Click Next> and you can test the regular expression.
Enter sample text and while it fails to match your regular expression, you see the error message in the title bar. Once it matches, the warning message changes to an information message telling you “The text matches the regular expression”.
It’s almost enough to make you want to prefer regular expressions for validating text fields.
I can see this getting a lot of use – thanks for blogging it
great article. how to invoke regex wizrd from xpage?
Great this makes life easier, Thanks for making my post more complete.
Regex is great and this makes it’s easier to use.
/Fredrik
That a great tip! I have been using http://regexpal.com/ a lot recently, and while it doesn’t have the easy builder that you showed here, it does have the really cool feature of showing you which parts of your expression matches which parts of your test strings.
Holy crap. If it’s that easy, even I might start using regex occasionally. 😉
Sorry, Tim, you can’t use that picker in Java, though I guess you could add it to any appropriate controls you build 😉
Where I can find Regular Expression Wizard?
how to invoke regex wizrd from xpage?
Hello, thanks for the tip. I use the QuickREx plugin, good for testing the regular expression, but id does not have a wizard…
Tell me…how do you install this or activate this? Im new to xpages and want to use this. Sounds cool.
Thanks
I believe that the editor itself is an Eclipse plugin and was not specifically designed for the Extension Library. It’s surfaced in the Dojo Validation Text Box, which is part of the Extension Library, available either in Upgrade Pack 1 for 8.5.3 or the OpenNTF project at http://extlib.openntf.org. I suspect you’ll need 8.5.3 as a minimum. I think the editor was added into the Domino Designer tooling later on in the evolution of the Extension Library. In future releases it may get added back into the other controls that support regular expression validators.
For those asking where to find it, it’s currently (8.5.3) only available on the Dojo Validation Text Box control, on the All Properties tab, on the regexp property.
Because it’s just an Eclipse editor, it may well get added back into other controls where appropriate in further releases.