0

How can i restrict Velocity Hash Map Object (say $ObjectName) to print fully if it is not preceded by property name.

i do not want $ObjectName to print full object value if it is not appended with variable/property name like $ObjectName.fieldName.

putting $ObjectName include entire detail in template while Velocity process the template

  • I understand that by _to print fully_ you mean _to display its content_. That should already be the case. Which version of Velocity are you using? You can also check the class of the map object with `$ObjectName.class.name` – Claude Brisson Jun 22 '16 at 07:39
  • I am Using Velocity 1.7. If we say ObjectName = ( field1="value1" , field2="value2", field3="value3" .. so on). then by printing my meaning is.. $ObjectName is printing { field1="value1" , field2="value2", fiedd3="value3" .. } . I don't want this complete value to get printed. Object field value should be printed if mentioned like $ObjectName.field1.. but $ObjectName should not print anything.. – Pankaj Sharma Jun 23 '16 at 12:56
  • Oh, so you want to *avoid* that. Sorry. So what do you want displayed, then? Something like 'Map@0x4e034534" ? Nothing? By the way, are you sure you can't just remove those references from the input template? – Claude Brisson Jun 24 '16 at 07:16
  • Hi, issue got resolved after implementing ReferenceInsertEventHandler Provided by Velocity. I gave implementation of renderInsert method and restrict all object except String. this method gets call just before PlaceHolder replace with actual value in Writer Object For More Info: http://stackoverflow.com/questions/375128/configure-velocity-to-render-an-object-with-something-other-than-tostring – Pankaj Sharma Jun 30 '16 at 10:45

0 Answers0