> -----Original Message----- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On > Behalf Of Geir Magnusson Jr. > Sent: Friday, May 25, 2001 6:09 PM > To: [EMAIL PROTECTED] > Subject: Re: a question about introspection and one about evaluation .. > ;) > > > David Esposito wrote: > > > > The question about introspection: > > > > I have an item on my context that is a string of length zero > (not null) ... > > So, in order for my display to work our properly, i need to > check the length > > before displaying the label in front of the text ... Why do i need the > > parentheses for the length method? Why can the intospection (along with > > trying getLength() getlength() get("length") just try the > method without any > > arguments? > > > > #if($item.catalog_item_manufacturer_no.length() > 0 ) > > Model# $item.catalog_item_manufacturer_no, > > #end > > I don't remember the exact reason why - however, I suspect that we are > trying to be as clean as we could with respect to the bean spec. It is > getting a touch 'sloppy', if you ask me... convenient though... It seems like there are only two options: one is to wrap my Strings in a StringWrapper where I implement getLength() ... the other is to allow the ".length" to call length() ... maybe ".length" should be specially implemented to also allow it to do a ".toString().length()" ... since sometimes Integer or other objects are on the Context and it would make it a universal way for designers to know whether an object has any information worth displaying ... without it, it seems like this goes against Velocity's mission of trying to keep Java details from template designers .. > > > I don't think so. 'null' evaluates to false, as does Boolean false. > > Everything else is true, and has been. > fair enough ... > geir > -Dave
