You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Mihai Gheorghiu <ta...@earthlink.net> on 2002/01/23 19:48:23 UTC

HashTable vs. Vector

It is my understanding after reading User's manual that if I want to print a
ResultSet I need to insert each row in a HashTable with the appropriate
column names, and each HashTable in a Vector or something else, so that
template.vm looks like:
<TABLE>
#foreach ($row in $ResultsVector)
<TR>
<TD>$row.Column1</TD>...<TD>$row.ColumnN</TD>
</TR>
#end
</TABLE>
This way I send the column names N times, once for each row in the
ResultSet.
If I had a method like
$row.elementAt(i)
I could insert each row in a vector, and each vector in the ResultsVector,
thus avoiding sending the column names.
Does it make sense?


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


Re: HashTable vs. Vector

Posted by Carsten Burghardt <cb...@magic-shop.de>.
On Wednesday 23 January 2002 19:48, you wrote:
> It is my understanding after reading User's manual that if I want to print
> a ResultSet I need to insert each row in a HashTable with the appropriate
> column names, and each HashTable in a Vector or something else, so that
> template.vm looks like:
> <TABLE>
> #foreach ($row in $ResultsVector)
> <TR>
> <TD>$row.Column1</TD>...<TD>$row.ColumnN</TD>
> </TR>
> #end
> </TABLE>
> This way I send the column names N times, once for each row in the
> ResultSet.
> If I had a method like
> $row.elementAt(i)
> I could insert each row in a vector, and each vector in the ResultsVector,
> thus avoiding sending the column names.
> Does it make sense?

You want to print the values of the ResultSet, don't you?
So you just put the values in Hashtables (or HashMaps):
while (rs.next()) {
HashMap values = new HashMap();
values.put("name", rs.getString("name"));
}
and this in a vector.
Perhaps I don't understand you right, I don't get the problem.

Regards,

Carsten
-- 
Carsten Burghardt
email: cb@magic-shop.de
WWW: http://www.magic-shop.de
PGP: http://www.magic-shop.de/Carsten_Burghardt.asc


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


Output padding

Posted by Corneil du Plessis <co...@mweb.co.za>.
I am using velocity and DVSL to generate code from a populated meta-model
and was if the following was possible?
I want to generate dynamic spacing to line elements in the code and exmaple
would be

#foreach( $field in $fieldlist )
	$field.attrib("type") $field.attrib("name") #tab(36) =
$field.attrib("default");
#end

This would mean that unless the output line position is past 36 spaces would
be generated until the output position is 36.

It is only for indentation purposes but may be useful when the output
language is something like Python.

Corneil du Plessis
(h) +27 (11) 918-1592
(w) +27 (82) 802-5768



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