You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by Bruce Altner <ba...@hq.nasa.gov> on 2001/11/10 21:46:56 UTC

dealing with Peer class output in the #foreach directive

Greeting:

Here's a real newbie question for you. It's driving me nuts. I am extending 
HelloWorld to be able to display database output so I set up a simple 
database of users and have my HelloWorldDB class query it using the 
doSelect() method in a UsersPeer class built by Ant, just as the docs 
suggest. I then put the resulting Vector users into the context object and 
try to pull it back out in the velocity template within a #foreach loop, 
for example #foreach ($user in $users):

It's crazy but I cannot for the life of me get Velocity to display the 
information correctly...no matter what kind of call I do on $user, which is 
supposed to be a row from the database, all it displays is the unrendered 
symbol: I tried properties, methods, everything. I know that the database 
part is working because I get the right number of rows back, but velocity 
seems to be unable to resolve it.

This should be very basic stuff. What do I need to do to get the column 
values for each row? What kind of Object is $user anyway? Is this a casting 
problem?

Thanks, in advance.

Bruce


_________________________________________________________________
"It's a magical world, Hobbes, ol' buddy...let's go exploring!" ---Calvin

Phone: 202-651-8553
Pager Email:8273479@skytel.com




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


Re: dealing with Peer class output in the #foreach directive

Posted by Bruce Altner <ba...@hq.nasa.gov>.
Thanks for the replies. Interesting discussion about Vector vs arrays. 
Actually, it wouldn't have mattered what type of collection I was using, I 
would still have gotten it wrong.

It seems I was doing everything right except for one funny little quirk 
that cost me an embarrassingly long time to discover. My database columns 
were called User_ID, User_Fname, and User_Lname so after sticking the 
Vector returned by doSelect(crit) into the context, as "users",  I 
naturally tried to retrieve them with $user.getUser_ID(), 
$user.getUser_Fname() and $user.getUser_Lname(), respectively.

Wrong! It seems that Torque, in building my BaseUsers class, decided that 
it didn't like the field names I had chosen so instead it defined the 
methods getUserId(), getUserFname() and getUserLname(). When I used these 
on the $user object it worked fine. Duh! I had read something about 
variable name rewriting under the Action Event How-to but I wasn't prepared 
for it here and wasn't experienced enough to know that I should examine the 
auto-generated BasePeer class for the right method names.

If this saves anybody similar heartache in the future, it was worth 
it.  Now on to bigger and better things in the life of a Turbine/Velocity 
newbie.

Bruce


At 10:13 PM 11/10/2001 -0800, you wrote:
>I don't think so, it actually may be a performance hit but I am not sure.  I
>plan on posting this to JUG that I attend to see if anyone knows for sure.
>r,
>Hugh
>----- Original Message -----
>From: "Dan Bachelder" <ch...@chowda.net>
>To: "Turbine Users List" <tu...@jakarta.apache.org>
>Sent: Saturday, November 10, 2001 7:12 PM
>Subject: Re: dealing with Peer class output in the #foreach directive
>
>
> > good point... do you think there is a performance gain to speak of?
> >
> > ----- Original Message -----
> > From: "Hugh Brien" <hp...@home.com>
> > To: "Turbine Users List" <tu...@jakarta.apache.org>
> > Sent: Sunday, November 11, 2001 1:10 AM
> > Subject: Re: dealing with Peer class output in the #foreach directive
> >
> >
> > > Just a preference.  I found it easier to work with arrays rather than
> > > Vectors in VM templates.  Plus there is not abiguitiy between the
> > developer
> > > and the template maintainer.
> > > r,
> > > Hugh
> > >
> > >
> > > ----- Original Message -----
> > > From: "Dan Bachelder" <ch...@chowda.net>
> > > To: "Turbine Users List" <tu...@jakarta.apache.org>
> > > Sent: Saturday, November 10, 2001 6:58 PM
> > > Subject: Re: dealing with Peer class output in the #foreach directive
> > >
> > >
> > > > out of curiosity.. why do you recommend using an array? a vector
> > iterates
> > > > fine..
> > > >
> > > > ----- Original Message -----
> > > > From: "Hugh Brien" <hp...@home.com>
> > > > To: "Turbine Users List" <tu...@jakarta.apache.org>
> > > > Sent: Sunday, November 11, 2001 12:51 AM
> > > > Subject: Re: dealing with Peer class output in the #foreach directive
> > > >
> > > >
> > > > > first of all make sure you don't have a conflict with any existing
> > refs
> > > to
> > > > > $user.   The simplest way to get things going is to convert the
>Vector
> > > to
> > > > an
> > > > > array before you push it into the context.   In your action class do
> > the
> > > > > following
> > > > >
> > > > > Vector vector = DocumentPeer.doSelect(new Criteria());
> > > > > Document[] documents = (Document[])vector.toArray(new Document[0]);
> > > > > context.put("documents", documents);
> > > > >
> > > > > then in your template you can do
> > > > >
> > > > > #foreach($document in $documents)
> > > > >     $document.getID ...
> > > > > #end
> > > > >
> > > > > From your code I am guessing that you are pulling user data from the
> > > > > TurbineSecurity api.  If so check the javadocs for the object types.
> > > > >
> > > > > r,
> > > > > Hugh
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > ----- Original Message -----
> > > > > From: "Bruce Altner" <ba...@hq.nasa.gov>
> > > > > To: <tu...@jakarta.apache.org>
> > > > > Sent: Saturday, November 10, 2001 12:46 PM
> > > > > Subject: dealing with Peer class output in the #foreach directive
> > > > >
> > > > >
> > > > > > Greeting:
> > > > > >
> > > > > > Here's a real newbie question for you. It's driving me nuts. I am
> > > > > extending
> > > > > > HelloWorld to be able to display database output so I set up a
> > simple
> > > > > > database of users and have my HelloWorldDB class query it using
>the
> > > > > > doSelect() method in a UsersPeer class built by Ant, just as the
> > docs
> > > > > > suggest. I then put the resulting Vector users into the context
> > object
> > > > and
> > > > > > try to pull it back out in the velocity template within a #foreach
> > > loop,
> > > > > > for example #foreach ($user in $users):
> > > > > >
> > > > > > It's crazy but I cannot for the life of me get Velocity to display
> > the
> > > > > > information correctly...no matter what kind of call I do on $user,
> > > which
> > > > > is
> > > > > > supposed to be a row from the database, all it displays is the
> > > > unrendered
> > > > > > symbol: I tried properties, methods, everything. I know that the
> > > > database
> > > > > > part is working because I get the right number of rows back, but
> > > > velocity
> > > > > > seems to be unable to resolve it.
> > > > > >
> > > > > > This should be very basic stuff. What do I need to do to get the
> > > column
> > > > > > values for each row? What kind of Object is $user anyway? Is this
>a
> > > > > casting
> > > > > > problem?
> > > > > >
> > > > > > Thanks, in advance.
> > > > > >
> > > > > > Bruce
> > > > > >

_________________________________________________________________
"It's a magical world, Hobbes, ol' buddy...let's go exploring!" ---Calvin

Phone: 202-651-8553
Pager Email:8273479@skytel.com




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


Re: dealing with Peer class output in the #foreach directive

Posted by Hugh Brien <hp...@home.com>.
I don't think so, it actually may be a performance hit but I am not sure.  I
plan on posting this to JUG that I attend to see if anyone knows for sure.
r,
Hugh
----- Original Message -----
From: "Dan Bachelder" <ch...@chowda.net>
To: "Turbine Users List" <tu...@jakarta.apache.org>
Sent: Saturday, November 10, 2001 7:12 PM
Subject: Re: dealing with Peer class output in the #foreach directive


> good point... do you think there is a performance gain to speak of?
>
> ----- Original Message -----
> From: "Hugh Brien" <hp...@home.com>
> To: "Turbine Users List" <tu...@jakarta.apache.org>
> Sent: Sunday, November 11, 2001 1:10 AM
> Subject: Re: dealing with Peer class output in the #foreach directive
>
>
> > Just a preference.  I found it easier to work with arrays rather than
> > Vectors in VM templates.  Plus there is not abiguitiy between the
> developer
> > and the template maintainer.
> > r,
> > Hugh
> >
> >
> > ----- Original Message -----
> > From: "Dan Bachelder" <ch...@chowda.net>
> > To: "Turbine Users List" <tu...@jakarta.apache.org>
> > Sent: Saturday, November 10, 2001 6:58 PM
> > Subject: Re: dealing with Peer class output in the #foreach directive
> >
> >
> > > out of curiosity.. why do you recommend using an array? a vector
> iterates
> > > fine..
> > >
> > > ----- Original Message -----
> > > From: "Hugh Brien" <hp...@home.com>
> > > To: "Turbine Users List" <tu...@jakarta.apache.org>
> > > Sent: Sunday, November 11, 2001 12:51 AM
> > > Subject: Re: dealing with Peer class output in the #foreach directive
> > >
> > >
> > > > first of all make sure you don't have a conflict with any existing
> refs
> > to
> > > > $user.   The simplest way to get things going is to convert the
Vector
> > to
> > > an
> > > > array before you push it into the context.   In your action class do
> the
> > > > following
> > > >
> > > > Vector vector = DocumentPeer.doSelect(new Criteria());
> > > > Document[] documents = (Document[])vector.toArray(new Document[0]);
> > > > context.put("documents", documents);
> > > >
> > > > then in your template you can do
> > > >
> > > > #foreach($document in $documents)
> > > >     $document.getID ...
> > > > #end
> > > >
> > > > From your code I am guessing that you are pulling user data from the
> > > > TurbineSecurity api.  If so check the javadocs for the object types.
> > > >
> > > > r,
> > > > Hugh
> > > >
> > > >
> > > >
> > > >
> > > > ----- Original Message -----
> > > > From: "Bruce Altner" <ba...@hq.nasa.gov>
> > > > To: <tu...@jakarta.apache.org>
> > > > Sent: Saturday, November 10, 2001 12:46 PM
> > > > Subject: dealing with Peer class output in the #foreach directive
> > > >
> > > >
> > > > > Greeting:
> > > > >
> > > > > Here's a real newbie question for you. It's driving me nuts. I am
> > > > extending
> > > > > HelloWorld to be able to display database output so I set up a
> simple
> > > > > database of users and have my HelloWorldDB class query it using
the
> > > > > doSelect() method in a UsersPeer class built by Ant, just as the
> docs
> > > > > suggest. I then put the resulting Vector users into the context
> object
> > > and
> > > > > try to pull it back out in the velocity template within a #foreach
> > loop,
> > > > > for example #foreach ($user in $users):
> > > > >
> > > > > It's crazy but I cannot for the life of me get Velocity to display
> the
> > > > > information correctly...no matter what kind of call I do on $user,
> > which
> > > > is
> > > > > supposed to be a row from the database, all it displays is the
> > > unrendered
> > > > > symbol: I tried properties, methods, everything. I know that the
> > > database
> > > > > part is working because I get the right number of rows back, but
> > > velocity
> > > > > seems to be unable to resolve it.
> > > > >
> > > > > This should be very basic stuff. What do I need to do to get the
> > column
> > > > > values for each row? What kind of Object is $user anyway? Is this
a
> > > > casting
> > > > > problem?
> > > > >
> > > > > Thanks, in advance.
> > > > >
> > > > > Bruce
> > > > >
> > > > >
> > > > > _________________________________________________________________
> > > > > "It's a magical world, Hobbes, ol' buddy...let's go
> > > exploring!" ---Calvin
> > > > >
> > > > > Phone: 202-651-8553
> > > > > Pager Email:8273479@skytel.com
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > --
> > > > > 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>
> > > >
> > > >
> > >
> > >
> > > --
> > > 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>
> >
> >
>
>
> --
> 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: dealing with Peer class output in the #foreach directive

Posted by Daniel Rall <dl...@finemaltcoding.com>.
The performance should be approximately the same.  In both cases an
Iterator implementation is used, and each data type used an array to
store its data internally.

"Dan Bachelder" <ch...@chowda.net> writes:

> good point... do you think there is a performance gain to speak of?
>
> ----- Original Message -----
> From: "Hugh Brien" <hp...@home.com>
> To: "Turbine Users List" <tu...@jakarta.apache.org>
> Sent: Sunday, November 11, 2001 1:10 AM
> Subject: Re: dealing with Peer class output in the #foreach directive
>
>
>> Just a preference.  I found it easier to work with arrays rather
>> than Vectors in VM templates.  Plus there is not abiguitiy between
>> the
> developer
> > and the template maintainer.

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


Re: dealing with Peer class output in the #foreach directive

Posted by Dan Bachelder <ch...@chowda.net>.
good point... do you think there is a performance gain to speak of?

----- Original Message -----
From: "Hugh Brien" <hp...@home.com>
To: "Turbine Users List" <tu...@jakarta.apache.org>
Sent: Sunday, November 11, 2001 1:10 AM
Subject: Re: dealing with Peer class output in the #foreach directive


> Just a preference.  I found it easier to work with arrays rather than
> Vectors in VM templates.  Plus there is not abiguitiy between the
developer
> and the template maintainer.
> r,
> Hugh
>
>
> ----- Original Message -----
> From: "Dan Bachelder" <ch...@chowda.net>
> To: "Turbine Users List" <tu...@jakarta.apache.org>
> Sent: Saturday, November 10, 2001 6:58 PM
> Subject: Re: dealing with Peer class output in the #foreach directive
>
>
> > out of curiosity.. why do you recommend using an array? a vector
iterates
> > fine..
> >
> > ----- Original Message -----
> > From: "Hugh Brien" <hp...@home.com>
> > To: "Turbine Users List" <tu...@jakarta.apache.org>
> > Sent: Sunday, November 11, 2001 12:51 AM
> > Subject: Re: dealing with Peer class output in the #foreach directive
> >
> >
> > > first of all make sure you don't have a conflict with any existing
refs
> to
> > > $user.   The simplest way to get things going is to convert the Vector
> to
> > an
> > > array before you push it into the context.   In your action class do
the
> > > following
> > >
> > > Vector vector = DocumentPeer.doSelect(new Criteria());
> > > Document[] documents = (Document[])vector.toArray(new Document[0]);
> > > context.put("documents", documents);
> > >
> > > then in your template you can do
> > >
> > > #foreach($document in $documents)
> > >     $document.getID ...
> > > #end
> > >
> > > From your code I am guessing that you are pulling user data from the
> > > TurbineSecurity api.  If so check the javadocs for the object types.
> > >
> > > r,
> > > Hugh
> > >
> > >
> > >
> > >
> > > ----- Original Message -----
> > > From: "Bruce Altner" <ba...@hq.nasa.gov>
> > > To: <tu...@jakarta.apache.org>
> > > Sent: Saturday, November 10, 2001 12:46 PM
> > > Subject: dealing with Peer class output in the #foreach directive
> > >
> > >
> > > > Greeting:
> > > >
> > > > Here's a real newbie question for you. It's driving me nuts. I am
> > > extending
> > > > HelloWorld to be able to display database output so I set up a
simple
> > > > database of users and have my HelloWorldDB class query it using the
> > > > doSelect() method in a UsersPeer class built by Ant, just as the
docs
> > > > suggest. I then put the resulting Vector users into the context
object
> > and
> > > > try to pull it back out in the velocity template within a #foreach
> loop,
> > > > for example #foreach ($user in $users):
> > > >
> > > > It's crazy but I cannot for the life of me get Velocity to display
the
> > > > information correctly...no matter what kind of call I do on $user,
> which
> > > is
> > > > supposed to be a row from the database, all it displays is the
> > unrendered
> > > > symbol: I tried properties, methods, everything. I know that the
> > database
> > > > part is working because I get the right number of rows back, but
> > velocity
> > > > seems to be unable to resolve it.
> > > >
> > > > This should be very basic stuff. What do I need to do to get the
> column
> > > > values for each row? What kind of Object is $user anyway? Is this a
> > > casting
> > > > problem?
> > > >
> > > > Thanks, in advance.
> > > >
> > > > Bruce
> > > >
> > > >
> > > > _________________________________________________________________
> > > > "It's a magical world, Hobbes, ol' buddy...let's go
> > exploring!" ---Calvin
> > > >
> > > > Phone: 202-651-8553
> > > > Pager Email:8273479@skytel.com
> > > >
> > > >
> > > >
> > > >
> > > > --
> > > > 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>
> > >
> > >
> >
> >
> > --
> > 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>
>
>


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


Re: dealing with Peer class output in the #foreach directive

Posted by Hugh Brien <hp...@home.com>.
Just a preference.  I found it easier to work with arrays rather than
Vectors in VM templates.  Plus there is not abiguitiy between the developer
and the template maintainer.
r,
Hugh


----- Original Message -----
From: "Dan Bachelder" <ch...@chowda.net>
To: "Turbine Users List" <tu...@jakarta.apache.org>
Sent: Saturday, November 10, 2001 6:58 PM
Subject: Re: dealing with Peer class output in the #foreach directive


> out of curiosity.. why do you recommend using an array? a vector iterates
> fine..
>
> ----- Original Message -----
> From: "Hugh Brien" <hp...@home.com>
> To: "Turbine Users List" <tu...@jakarta.apache.org>
> Sent: Sunday, November 11, 2001 12:51 AM
> Subject: Re: dealing with Peer class output in the #foreach directive
>
>
> > first of all make sure you don't have a conflict with any existing refs
to
> > $user.   The simplest way to get things going is to convert the Vector
to
> an
> > array before you push it into the context.   In your action class do the
> > following
> >
> > Vector vector = DocumentPeer.doSelect(new Criteria());
> > Document[] documents = (Document[])vector.toArray(new Document[0]);
> > context.put("documents", documents);
> >
> > then in your template you can do
> >
> > #foreach($document in $documents)
> >     $document.getID ...
> > #end
> >
> > From your code I am guessing that you are pulling user data from the
> > TurbineSecurity api.  If so check the javadocs for the object types.
> >
> > r,
> > Hugh
> >
> >
> >
> >
> > ----- Original Message -----
> > From: "Bruce Altner" <ba...@hq.nasa.gov>
> > To: <tu...@jakarta.apache.org>
> > Sent: Saturday, November 10, 2001 12:46 PM
> > Subject: dealing with Peer class output in the #foreach directive
> >
> >
> > > Greeting:
> > >
> > > Here's a real newbie question for you. It's driving me nuts. I am
> > extending
> > > HelloWorld to be able to display database output so I set up a simple
> > > database of users and have my HelloWorldDB class query it using the
> > > doSelect() method in a UsersPeer class built by Ant, just as the docs
> > > suggest. I then put the resulting Vector users into the context object
> and
> > > try to pull it back out in the velocity template within a #foreach
loop,
> > > for example #foreach ($user in $users):
> > >
> > > It's crazy but I cannot for the life of me get Velocity to display the
> > > information correctly...no matter what kind of call I do on $user,
which
> > is
> > > supposed to be a row from the database, all it displays is the
> unrendered
> > > symbol: I tried properties, methods, everything. I know that the
> database
> > > part is working because I get the right number of rows back, but
> velocity
> > > seems to be unable to resolve it.
> > >
> > > This should be very basic stuff. What do I need to do to get the
column
> > > values for each row? What kind of Object is $user anyway? Is this a
> > casting
> > > problem?
> > >
> > > Thanks, in advance.
> > >
> > > Bruce
> > >
> > >
> > > _________________________________________________________________
> > > "It's a magical world, Hobbes, ol' buddy...let's go
> exploring!" ---Calvin
> > >
> > > Phone: 202-651-8553
> > > Pager Email:8273479@skytel.com
> > >
> > >
> > >
> > >
> > > --
> > > 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>
> >
> >
>
>
> --
> 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: dealing with Peer class output in the #foreach directive

Posted by Dan Bachelder <ch...@chowda.net>.
out of curiosity.. why do you recommend using an array? a vector iterates
fine..

----- Original Message -----
From: "Hugh Brien" <hp...@home.com>
To: "Turbine Users List" <tu...@jakarta.apache.org>
Sent: Sunday, November 11, 2001 12:51 AM
Subject: Re: dealing with Peer class output in the #foreach directive


> first of all make sure you don't have a conflict with any existing refs to
> $user.   The simplest way to get things going is to convert the Vector to
an
> array before you push it into the context.   In your action class do the
> following
>
> Vector vector = DocumentPeer.doSelect(new Criteria());
> Document[] documents = (Document[])vector.toArray(new Document[0]);
> context.put("documents", documents);
>
> then in your template you can do
>
> #foreach($document in $documents)
>     $document.getID ...
> #end
>
> From your code I am guessing that you are pulling user data from the
> TurbineSecurity api.  If so check the javadocs for the object types.
>
> r,
> Hugh
>
>
>
>
> ----- Original Message -----
> From: "Bruce Altner" <ba...@hq.nasa.gov>
> To: <tu...@jakarta.apache.org>
> Sent: Saturday, November 10, 2001 12:46 PM
> Subject: dealing with Peer class output in the #foreach directive
>
>
> > Greeting:
> >
> > Here's a real newbie question for you. It's driving me nuts. I am
> extending
> > HelloWorld to be able to display database output so I set up a simple
> > database of users and have my HelloWorldDB class query it using the
> > doSelect() method in a UsersPeer class built by Ant, just as the docs
> > suggest. I then put the resulting Vector users into the context object
and
> > try to pull it back out in the velocity template within a #foreach loop,
> > for example #foreach ($user in $users):
> >
> > It's crazy but I cannot for the life of me get Velocity to display the
> > information correctly...no matter what kind of call I do on $user, which
> is
> > supposed to be a row from the database, all it displays is the
unrendered
> > symbol: I tried properties, methods, everything. I know that the
database
> > part is working because I get the right number of rows back, but
velocity
> > seems to be unable to resolve it.
> >
> > This should be very basic stuff. What do I need to do to get the column
> > values for each row? What kind of Object is $user anyway? Is this a
> casting
> > problem?
> >
> > Thanks, in advance.
> >
> > Bruce
> >
> >
> > _________________________________________________________________
> > "It's a magical world, Hobbes, ol' buddy...let's go
exploring!" ---Calvin
> >
> > Phone: 202-651-8553
> > Pager Email:8273479@skytel.com
> >
> >
> >
> >
> > --
> > 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>
>
>


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


Re: dealing with Peer class output in the #foreach directive

Posted by Hugh Brien <hp...@home.com>.
first of all make sure you don't have a conflict with any existing refs to
$user.   The simplest way to get things going is to convert the Vector to an
array before you push it into the context.   In your action class do the
following

Vector vector = DocumentPeer.doSelect(new Criteria());
Document[] documents = (Document[])vector.toArray(new Document[0]);
context.put("documents", documents);

then in your template you can do

#foreach($document in $documents)
    $document.getID ...
#end

>From your code I am guessing that you are pulling user data from the
TurbineSecurity api.  If so check the javadocs for the object types.

r,
Hugh




----- Original Message -----
From: "Bruce Altner" <ba...@hq.nasa.gov>
To: <tu...@jakarta.apache.org>
Sent: Saturday, November 10, 2001 12:46 PM
Subject: dealing with Peer class output in the #foreach directive


> Greeting:
>
> Here's a real newbie question for you. It's driving me nuts. I am
extending
> HelloWorld to be able to display database output so I set up a simple
> database of users and have my HelloWorldDB class query it using the
> doSelect() method in a UsersPeer class built by Ant, just as the docs
> suggest. I then put the resulting Vector users into the context object and
> try to pull it back out in the velocity template within a #foreach loop,
> for example #foreach ($user in $users):
>
> It's crazy but I cannot for the life of me get Velocity to display the
> information correctly...no matter what kind of call I do on $user, which
is
> supposed to be a row from the database, all it displays is the unrendered
> symbol: I tried properties, methods, everything. I know that the database
> part is working because I get the right number of rows back, but velocity
> seems to be unable to resolve it.
>
> This should be very basic stuff. What do I need to do to get the column
> values for each row? What kind of Object is $user anyway? Is this a
casting
> problem?
>
> Thanks, in advance.
>
> Bruce
>
>
> _________________________________________________________________
> "It's a magical world, Hobbes, ol' buddy...let's go exploring!" ---Calvin
>
> Phone: 202-651-8553
> Pager Email:8273479@skytel.com
>
>
>
>
> --
> 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: dealing with Peer class output in the #foreach directive

Posted by Peter Lynch <pe...@mindspring.com>.
----- Original Message -----
From: "Bruce Altner" <ba...@hq.nasa.gov>
To: <tu...@jakarta.apache.org>
Sent: Saturday, November 10, 2001 12:46 PM
Subject: dealing with Peer class output in the #foreach directive


<snip>

> It's crazy but I cannot for the life of me get Velocity to display the
> information correctly...no matter what kind of call I do on $user, which
is
> supposed to be a row from the database, all it displays is the unrendered
> symbol: I tried properties, methods, everything. I know that the database
> part is working because I get the right number of rows back, but velocity
> seems to be unable to resolve it.

So you know that the vector contains objects before it goes into the
context?
What goes in the context is what comes out...

What happend when you just put

$users

in the template?

If you don't see a string representation of the data then go back into where
you think you put it into the context with data and recheck.

Or try $users.size()
If you see a number and not $users.size(), at least you know you have users
in the context correctly.

The best way to check all of this is to tell velocity via properties to log
everything. Then look in the velocity log. It will usually give you a useful
log statement.

See the velocity manual for hints on how to do that. You'll also get better
support for velocity specific questions on
velocity-user@jakarta.apache.org., although that peer stuff is definitely
turbine related.

-Peter

>
> This should be very basic stuff. What do I need to do to get the column
> values for each row? What kind of Object is $user anyway? Is this a
casting
> problem?
>
> Thanks, in advance.
>
> Bruce
>
>
> _________________________________________________________________
> "It's a magical world, Hobbes, ol' buddy...let's go exploring!" ---Calvin
>
> Phone: 202-651-8553
> Pager Email:8273479@skytel.com
>
>
>
>
> --
> 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>