Those braces go around everything in the velocity reference.

${res}.getN()

should be

${res.getN()}

And you don't even need them.  Also, since getN() follows a java beans
getter pattern, you can just say:

$res.n  or $res.N


 I can never remember what happens with a single letter JavaBeans signature.


On Sat, Feb 13, 2010 at 2:13 PM, danny van elsen
<[email protected]> wrote:
> hello all,
>
> I'm new to velocity, and I'm trying to get something general to work for
> different kinds of inputs + templates.
>
> I'm doing something like:
>
> *******************
> class Velo {
>
> public static StringList [] stringlist;
>
> public static void main(String[] args)
> {
> Velo v = new Velo();
> v.run(args);
> }
>
> public void run (String[] args)
> {
> ...fill stringlists with data ...
>
> ... initialise velocity ...
>
>  for (i = 0; i < ... ; i++)
>   context.put(el_name[i], stringlist[i].sl);
> ...
> }
> }
>
> ***********************************
>
> public class StringList
> {
>  public String name;
>
>  public StringRow [] sl;
>
>  public StringList()
>  {
>   name = "";
>   ... initialse stringrows ...
>  }
> }
>
> ************************************
>
> public class StringRow
> {
>  public String N;
>
>  public ArrayList <String> sr;
>
>  public StringRow()
>  {
>   sr = new ArrayList <String> ();
>  }
>
>  public String getN()
>  {
>   return N;
>  }
> }
>
> ************************************
>
> but when running the template entry
>
> #foreach( $res in $result )
>   <td>  ${res}.getN() </td>
> #end
>
> I'm only getting
> <td>  [email protected]() </td>
> = the method getN() isn't being translated in to the underlying String
>
> so my questions are :-)
> 1.  why won't this work?
>
> 2.  can something like  <td>  ${res}.sr.get(0) </td> work?
> i.e.  calling a method (= get(0))  on a field (sr) of the context
> element (${res}) that is actually an array?
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to