Cameron Ingram0 wrote:
> Hi all, I could use some help with the iterate tag. I am passing a
> Hashtable to the iterate class. I loaded my hash table withan integer
> object(incremented with every object I put in the table) and I create
> an anonymous object. Now I have checked and everything seems to be
> fineup until the point that I need to iterate through the hash table
> and pull the properties. It doesn't seem to be iterating through. I
> checked my Hashtableand it does have values, and the properties of my
> objects are getting filled. So I guess I have 2 questions, what does
> the iterate class use for key values or am I way offtrack in
> populating my table like this? Hashtable impl = new
> Hashtable();Integer sKeyValue;int keyValue = 0;
> query = getRs();//getting the result set from my query.try{
> while(query.next()){ impl.put(sKeyValue = new
> Integer(keyValue), new Implementation() } keyValue = keyValue +
> 1;
> }
> query.close();
> }
> catch(SQLException e){
> System.out.println("Error code: " + e.getErrorCode());
> } jsp...<logic:iterate id="impl" name="loadImpl"
> property="impl"> thanks in advance!!Cameron
When you iterate over a Hashtable (or any other Map), the elements of
the iteration are of class "Map.Entry", which has two properties --
"key" and "value".
<logic:iterate id="impl" name="loadImpl" property="impl">
The curent value is <bean:write name="impl" property="value"/>
</logic:iterate>
However, to accomplish what you are doing above, a Hashtable seems like
overkill -- if you used an ArrayList or Vector instead, the iterator
would be on the elements themselves, and you would not need any extra
property accessors.
<logic:iterate id="impl" name="loadImpl" property="impl">
The current value is <bean:write name="impl"/>
</logic:iterate>
Craig McClanahan