[antlr-interest] string template v4 list of object iteration

Pradeep Vasudevan pradeep.v at cordic.com
Thu May 3 10:14:45 PDT 2012

Hi All

(finally my interest list confirmation mail turned up :) )

I have used stringtemplatev3 in one of my .net project

in v3, if I have arraylist of objects I can iterate thru the list by
in my html page ,

$arrayListOfPersons :{ p |

where person class is declared in java

class persons{
public String getName();
public int getAge();

List<persons>  ps = new ArrayList<persons>();
add persons to ps

but now I am using a string template group file(.stg) with stringtempate V4
I am getting exception on above html table iteration code
some of the stack trace says
can't load group file
Caused by: java.lang.ClassCastException: java.util.ArrayList
at org.antlr.runtime.tree.BaseTreeAdaptor.addChild(BaseTreeAdaptor.java:107)
at org.stringtemplate.v4.compiler.STParser.mapExpr(STParser.java:3508)

at the same time I can list an array of string like this $contents; separator="<br/>"$

(we use $ for delimiters in v3 and v4)

how do I iterate a list of object in a list in ST version 4 using string template group file?
is my syntax is wrong ? I can provide more info about java classes/more stack trace etcetc (someoneelse in my team wrote it)
if required

any help/tips would be greatful
thanks in advance


More information about the antlr-interest mailing list