I have a printed export from an html file that it takes imports from a Map as shown below
Template t = TemplateLoader.load("Printing/acount.html");
Map<String, Object> map = new HashMap<String, Object>();
map.put("accountName ", e.accountName);
map.put("accountAmount ", acAmount);
return t.render(map);
And loads the parametres to the html file
<div>
Account: <font size="3"><b>${ accountName }</b> ${accountAmount}</font> <br/>
And its export looks like
Account 15884 5.000
What if I want to have multiple records in my export?
Lets say
Account 15885 2.000
Account 15886 4.000
Account 15887 3.000
How should be the html and java code in the second case in order to pas an uknown number of records?
You are now creating a
Mapwith values foraccountNameandaccountAmount. What you should do is add a list of objects that each contain a value foraccountNameandaccountAmount.It would look something like this:
In your template you can then iterate over the items in
${ accounts }(e.g., for eachaccountinaccounts) and print each value ofaccount.nameandaccount.amount.I’m not familiar with the exact syntax of these templates but the approach should be along these lines.