« Return to Thread: Can't iterater ArrayList?

Can't iterater ArrayList<PoJoObject>?

by Mead Lai :: Rate this Message:

Reply to Author | View in Thread

Hi,
   I am a newer, please bear my ignorance.
I have a PoJo java class, it have more than two propertys, so HashMap
is useless. The code is like this:

public class Property {
        public String n;
        public String k;
        public String vCH;
        public String vEN;
///pass over the geter & seter
}

I put the ArrayList<Property> in the VelocityContext.

ArrayList<Property> props = new  ArrayList<Property>();
props.add();//add some object of Property
VelocityContext.put("prop", props);

The Template file is like that:

#foreach(${p} in ${prop})
${p}"
 key="${p.k}"
 label="${p.l}"
#end

The result is display:

com.demo.tools.velocity.Property@c21495"
 key="${p.k}"
 label="${p.l}"
com.demo.tools.velocity.Property@15f5897"
 key="${p.k}"
 label="${p.l}"

It can get ${p}, but can't get the field of $p.
HashMap<String,String> is iterator ok, It's the Velocity can't
iterater ArrayList<PoJoObject>?
Appreciate with U answer.

Mead Lai
www.yayisoft.com

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@...
For additional commands, e-mail: user-help@...

 « Return to Thread: Can't iterater ArrayList?

LightInTheBox - Buy quality products at wholesale price