velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claude Brisson <cla...@renegat.net>
Subject Re: Dynamically generated values
Date Mon, 27 Mar 2006 16:58:35 GMT
Sorry.

You should read
	$render.evaluate($context,"\$entry_$id")
and
	$render.evaluate("\$entry_$id")

  Claude

> 
>         if not, then use the RenderTool; you will also need $context as
>         in 2
> 	$render.evaluate($context,"entry_$id")
> 


Le lundi 27 mars 2006 à 18:50 +0200, Claude Brisson a écrit :
> Hi.
> 
> There are several solutions.
> 
> 1. You can put the key/value pairs in a map that you put in the context:
> 	$catalog.get("entry_$id")
> 
> 2. You can put the context inside itself
> 	$context.get("entry_$id")
> 
> 3. A more generic solution is to use a render tool from the
> velocity-tools subproject.
>    
>         If you are using the VelocityViewServlet, you can use the
>         ViewRenderTool :
>         	$render.evaluate("$entry_$id")
> 
>         if not, then use the RenderTool; you will also need $context as
>         in 2
> 	$render.evaluate($context,"entry_$id")
> 
>   --
>   Claude
> 
> Le lundi 27 mars 2006 à 16:45 +0200, Thomas Peter Berntsen a écrit :
> > Hi guys
> > 
> > I'm using velocity to generate a 5x5 matrix with each entry having its 
> > own id like this:
> > 
> > <table style="border:1px solid black;">z
> > 		*#foreach* ($row in $rows)
> > 		<tr>
> > 			*#foreach* ($col in $cols)
> > 			*#set*( $product = $col * $row )
> > 			*#set*( $id = "$col$row" )
> > 			<td>
> > 				Row: $row, Column: $col <br/>
> > 				Number: $id
> > 			</td>
> > 			*#end*
> > 		</tr>
> > 		*#end*
> > 	</table>
> > 
> > The template gets $rows and $cols, two int[]s containing values 1 through 5.
> > 
> > The $id is a string concatenation of $col and $row.
> > 
> > I am passing a key-value pairs - eg. ("entry_15", "FOO") to the template 
> > as well, where the key corresponds to the entry in the matrix in which 
> > the value should be shown.
> > 
> > How do I accomplish this?
> > 
> > I know that I would normally address the key to get the value like 
> > $entry_15, but the "15" is the dynamically generated value from the 
> > Velocity template itself (what is $id in the example above)... So I need 
> > something like $entry_#generateValue where" #generateValue" is a macro 
> > which precedes the "$entry_".
> > 
> > I've tried a lot of things, but it's all erraneous.
> > 
> > I look forward to hearing from you.
> > 
> > Cheers,
> > Thomas
> > 
> > 
> > 
> > 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
> 


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


Mime
View raw message