StringUtils in ATG Dynamo

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.


Posted

in

by

Tags:

Comments

2 responses to “StringUtils in ATG Dynamo”

  1. Monsoon Avatar
    Monsoon

    Thanks, nice explanation of this undocumented util class. I was looking for the differences between those two methods.

  2. Timothy Avatar
    Timothy

    thanks. It helps me a lot!

Leave a Reply

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

PHP Code Snippets Powered By : XYZScripts.com