velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From JDigg...@genelogic.com
Subject string/integer comparison
Date Fri, 13 Dec 2002 18:48:47 GMT

I attempted to check the archives for an answer but there are so many
emails dealing with floats v. ints, etc. that the signal to noise ratio
defeated me -- so I'm asking ...

If I want to optionally show a particular item as selected in a list box
based on a passed ID. $selected below is pulled from $data.getParameters
().getString("category_id") and $cat.CategoryId is the primary key for the
Category table. I've tried the two versions below and they all constantly
return false, no matter what. I'm assuming this is because $cat.CategoryId
returns an int from a NumberKey and $selected is a string:

      <option value="$cat.CategoryId"
            #if( $cat.CategoryId == $selected ) SELECTED#end>
            $cat.Name
      </option>

      <option value="$cat.CategoryId"
            #if( $cat.CategoryId.equals($selected )) SELECTED#end>
            $cat.Name
      </option>

Would I get around this by creating a method in Category that casts the
CategoryId to a string and returns it? Would .equals() then return true?
Thanks ... still trying to get a handle on Velocity's typing.
-j

-------------------------------------------------
James Diggans
Bioinformatics Programmer
Gene Logic, Inc.
Phone: 301.987.1756
FAX: 301.987.1701





--
To unsubscribe, e-mail:   <mailto:velocity-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:velocity-user-help@jakarta.apache.org>


Mime
View raw message