I HATE velocity and rarely ever use it but sometimes I am called upon at my job to do so. I can never really figure out just how to use it.
I have this
#foreach( $product in $browseSiteProducts )
#foreach( $stringList in $product.productId.split("|") )
Velocity has extremely few objects and methods of its own. Instead, it allows you to work with real Java objects and call real Java methods on those objects. Which Velocity documentation says that the delimiter is a string?
Moreover, since Velocity is Java-based, a
string is just a data type that can hold many types of information: phone numbers, names, identifiers, regular expressions... In Java, many methods dealing with regular expressions pass those REs as
You can check the actual type that a value behind a variable has by printing its classname:
Product class is $product.class Product ID class is $product.productId.class
| is a special character in regular expressions, you need to escape it somehow. This works:
#foreach( $stringList in $product.productId.split("[|]") )