velocity (test instanceof)
There is no instanceof, but you can get class name as a string and then go from there: ${myObj.class.name} would return “com.test.MyObj” ${myObj.class.simpleName} would return “MyObj”
There is no instanceof, but you can get class name as a string and then go from there: ${myObj.class.name} would return “com.test.MyObj” ${myObj.class.simpleName} would return “MyObj”
If you just want Velocity to display the value if there, or display nothing if absent, a quiet reference by itself will do the trick: $!incentive.disclaimer If you’re wanting to explicitly test for empty, StringUtils from Apache Commons Lang can help. First add it to your Context (reference here): context.put(“StringUtils”, StringUtils.class); Though if you’re on … Read more
Aha! Been there. #set($intString = “9”) #set($Integer = 0) $Integer.parseInt($intString) Doing this uses the java underlying velocity. The $Integer variable is nothing more that a java Integer object which you can then use to access .parseInt Edit: The above code is for demonstration. Of course there are ways to optimize it.
this: #[[ ## ]]# will yield: ## anything within #[[ … ]]# is unparsed.