Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7920109
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T16:05:37+00:00 2026-06-03T16:05:37+00:00

heres my test in java public class person { public String name; public int

  • 0

heres my test in java

public class person
{
    public String name;
    public int age;
    public String getName() { return name; }
    public int getAge() { return age; }
}

In my function I create a number of person objects
and add it into an list

ArrayList<person> arr = new ArrayList<person>()
arr.add(person1);
arr.add(person2); etc etc

in the string template group file I have got

test(arr) ::= <<
 <table>
 $arr: {a|
 <tr><td>$a.name$</td><td>$a.age$</td></tr>
 }$
 </table>
>>

this is called from my list template

list (arr) ::= <<

$test(arr)$

... and other page details etc
>>

in version4 for I get template not found message with some stack trace as follows

Caused by: java.lang.ClassCastException: java.util.ArrayList
at org.antlr.runtime.tree.RewriteRuleTokenStream.nextNode(RewriteRuleTokenStream.java:58)
at org.stringtemplate.v4.compiler.STParser.subtemplate(STParser.java:1563)
at org.stringtemplate.v4.compiler.STParser.mapTemplateRef(STParser.java:3692)

but I can list an array as follows and it prints the object representation in string format
(also I can use a map – ie key value pairs works ok too)

in string template

test(arr) :: =<<
 <p>
 $arr; seperator="</br>"$
 </p>
>>

how do we iterate list of object to print field values using string template grop in V4
am I using it in a wrong format/syntax?

any help/points would be greateful

note: we set $ as delimiter using new STGroupString(“”, templateGroup, ‘$’, ‘$’);

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T16:05:38+00:00Added an answer on June 3, 2026 at 4:05 pm

    You are missing the terminating $ on your expression: $a.age should be $a.age$

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've the following classes KeyValue.java package test; public class KeyValue<T> { private String key;
I have the following java code: public class CheckInnerStatic { private static class Test
Here is a test class: import java.lang.annotation.Annotation; import java.lang.reflect.Method; public class TestAnnotations { @interface
Given the following Java code: public class Test { static private class MyThread extends
I have defined the following Unit-Test: [TestMethod] //@Test for the Java crowd public void
I have a static class (Foo) and a main class (Main) See Main.java: public
My SSCE: public class ComparableItem implements Comparable<ComparableItem> { private final int itemNo; public ComparableItem(final
I often hear around here from test driven development people that having a function
Here is a test description, testing the Create New Widget use-case. Confirm that you
Here's the simple test to reproduce the issue, this is the single class in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.