Hi Bruce, That is standard operating procedure for Torque. It will automatically convert a column name in a schema from FOO_BAR to an accessor method getFooBar() and setFooBar(). I actually like this because you end up with standardized java naming of methods. However, if you do not like the names Torque gives your accessor methods or peers you can always specify the "javaName" attribute in either the column tag or the table tag.
example: <column name="Foo_Bar" type"VARCHAR" size="50" javaName="Foo_Bar"> I find this helpful if I am connecting up to a legacy DB that has non-descriptive table/column names. Scott -----Original Message----- From: Bruce Altner [mailto:[EMAIL PROTECTED]] Sent: Sunday, November 11, 2001 4:57 AM To: Turbine Users List Subject: Re: dealing with Peer class output in the #foreach directive 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" <[EMAIL PROTECTED]> >To: "Turbine Users List" <[EMAIL PROTECTED]> >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" <[EMAIL PROTECTED]> > > To: "Turbine Users List" <[EMAIL PROTECTED]> > > 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" <[EMAIL PROTECTED]> > > > To: "Turbine Users List" <[EMAIL PROTECTED]> > > > 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" <[EMAIL PROTECTED]> > > > > To: "Turbine Users List" <[EMAIL PROTECTED]> > > > > 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" <[EMAIL PROTECTED]> > > > > > To: <[EMAIL PROTECTED]> > > > > > 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:[EMAIL PROTECTED] -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
