Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How I hide empty Velocity variable names?

I am using Struts + Velocity in a Java application, but after I submit a form, the confirmation page (Velocity template) shows the variable names instead an empty label, like the Age in following example:

Name: Fernando

Age: {person.age}

Sex: Male

I would like to know how to hide it!

like image 827
Fernando Barrocal Avatar asked Aug 23 '08 02:08

Fernando Barrocal


2 Answers

You can mark variables as "silent" like this:

$!variable

If $variable is null, nothing will be rendered. If it is not null, its value will render as it normally would.

like image 128
Jason Sparks Avatar answered Oct 17 '22 21:10

Jason Sparks


You will also need to be sure and use the proper syntax. Your example is missing the dollar before the variable. It should be $!{person.age}, not just {person.age}.

like image 33
Nathan Bubna Avatar answered Oct 17 '22 23:10

Nathan Bubna