You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Jan Vesely <ja...@quinity.com> on 2002/11/26 11:03:18 UTC

#foreach help needed ...

Hi everyone,

I wonder if the following thing is possible, and if it is, how to make Velocity do it...(i simplify the real situation & use different classes, but the problem is the same):


I have one class, say class Person with following fields: String name, ArrayList addresses
Then I have another class, Address, with fields String street, String city - you can guess, the ArrayList addresses in Person is filled with instances of the class Address.
And I have a wrapper ArrayList People.

Now I want to print all the information I have
so I do

#foreach($person in $people)
$person.name
#foreach($address in $person.addresses)
$address.street
$address.city       
#end     
#end

However, I do not get the address data ... anyone any idea why? I do not have any problems with accessing simple stuf like String inside an ArrayList. I also do not have any problems with getting the whole Address object (which is, of course, gibberish when printed as it is). What I cannot achieve is to acces the fields of the Address object from the ArrayList ....

Thanks!!!

Jan



RE: #foreach help needed ...

Posted by Peter Romianowski <me...@gmx.de>.
> You're right!
> it was a really STUPID mistake - my getters & setters were 
> "protected" ... thanks a lot and sorry for bothering you! 
> Everything works fine now!

Fine! And *no problem*!

Peter


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: #foreach help needed ...

Posted by Jan Vesely <ja...@quinity.com>.
You're right!
it was a really STUPID mistake - my getters & setters were "protected"
... thanks a lot and sorry for bothering you! Everything works fine now!



----- Original Message -----
From: "Peter Romianowski" <me...@gmx.de>
To: "'Velocity Users List'" <ve...@jakarta.apache.org>; "'Jan
Vesely'" <ja...@quinity.com>
Sent: Tuesday, November 26, 2002 12:09 PM
Subject: RE: #foreach help needed ...


>   Do you have getters for the address-properties? Like
> Address.getStreet()?
> And are they public? Could you please send the Java-Files too, if the
> problem persists?
>
>   I don't see any problem besides the property-thing (at the moment).
>
> Peter
>
> > -----Original Message-----
> > From: Jan Vesely [mailto:jan.vesely@quinity.com]
> > Sent: Tuesday, November 26, 2002 11:03 AM
> > To: Velocity Users List
> > Subject: #foreach help needed ...
> >
> >
> > Hi everyone,
> >
> > I wonder if the following thing is possible, and if it is,
> > how to make Velocity do it...(i simplify the real situation &
> > use different classes, but the problem is the same):
> >
> >
> > I have one class, say class Person with following fields:
> > String name, ArrayList addresses Then I have another class,
> > Address, with fields String street, String city - you can
> > guess, the ArrayList addresses in Person is filled with
> > instances of the class Address. And I have a wrapper ArrayList People.
> >
> > Now I want to print all the information I have
> > so I do
> >
> > #foreach($person in $people)
> > $person.name
> > #foreach($address in $person.addresses)
> > $address.street
> > $address.city
> > #end
> > #end
> >
> > However, I do not get the address data ... anyone any idea
> > why? I do not have any problems with accessing simple stuf
> > like String inside an ArrayList. I also do not have any
> > problems with getting the whole Address object (which is, of
> > course, gibberish when printed as it is). What I cannot
> > achieve is to acces the fields of the Address object from the
> > ArrayList ....
> >
> > Thanks!!!
> >
> > Jan
> >
> >
> >
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: #foreach help needed ...

Posted by Peter Romianowski <me...@gmx.de>.
  Do you have getters for the address-properties? Like
Address.getStreet()?
And are they public? Could you please send the Java-Files too, if the
problem persists?

  I don't see any problem besides the property-thing (at the moment).

Peter

> -----Original Message-----
> From: Jan Vesely [mailto:jan.vesely@quinity.com] 
> Sent: Tuesday, November 26, 2002 11:03 AM
> To: Velocity Users List
> Subject: #foreach help needed ...
> 
> 
> Hi everyone,
> 
> I wonder if the following thing is possible, and if it is, 
> how to make Velocity do it...(i simplify the real situation & 
> use different classes, but the problem is the same):
> 
> 
> I have one class, say class Person with following fields: 
> String name, ArrayList addresses Then I have another class, 
> Address, with fields String street, String city - you can 
> guess, the ArrayList addresses in Person is filled with 
> instances of the class Address. And I have a wrapper ArrayList People.
> 
> Now I want to print all the information I have
> so I do
> 
> #foreach($person in $people)
> $person.name
> #foreach($address in $person.addresses)
> $address.street
> $address.city       
> #end     
> #end
> 
> However, I do not get the address data ... anyone any idea 
> why? I do not have any problems with accessing simple stuf 
> like String inside an ArrayList. I also do not have any 
> problems with getting the whole Address object (which is, of 
> course, gibberish when printed as it is). What I cannot 
> achieve is to acces the fields of the Address object from the 
> ArrayList ....
> 
> Thanks!!!
> 
> Jan
> 
> 
> 


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>