I have created map which contains the postal address which is finally pass to homeAddress map .See the below code
Map map1 = new HashMap();
map1.put("address", "address1 trinity");
map1.put("address2", "addressmg road");
map1.put("city", "bangalore");
map1.put("state", "karnataka");
Map map2 = new HashMap();
map2.put("postal_address",map1);
VelocityContext context = new VelocityContext();
context.put("homeAddress",map2);
Template code:
Variable Declaration:
#set ($PostalAddress_Address2 ="address2")
#set ($PostalAddress_City ="city")
#set ($PostalAddress_State ="state")
Iterating the Map:
#set($tocList=${homeAddress.postal_address})
$tocList.get($PostalAddress_Address2)
$tocList.get($PostalAddress_State)
$tocList.get($PostalAddress_City)
The above code works fine.But when i replace the variable Declaration for postal_address_main as postal_address then its not working
#set ($postal_address_main ="postal_address")
#set($tocList=${homeAddress.postal_address_main })
Any suggestion on this? how to replace the Variable declaration while fetching the value from map?