A hidden gem in ATG Dynamo is the simple, but VERY useful, and totally undocumented StringUtils class. It lives in the atg.core.util package in DAS/lib/classes.jar. It has several methods, but the most commonly used are isEmpty(String) and isBlank(String). Both return a boolean, and are very useful for validating form input and the like.
One thing to note is the important difference between the two methods. isEmpty() will return true for a null or a String with a length of zero. isBlank() will return true for null, or a String with a length of zero, OR a String of just whitespace. It basically adds a trim() call to it’s checks.
So when you’re validating user input, use isBlank() not isEmpty() otherwise you can easily end up with a database full of single space, ” “, names, passwords, e-mails, etc….
Remember, using undocumented classes or APIs is at your own risk, however this class, and these methods have been around for ages and are pretty stable.
Leave a Reply