You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by "Nadesan, Binu" <bn...@cincom.com> on 2004/12/10 22:14:44 UTC

Problems with ViewRenderTool

Hi All,

I have problem with the Velocity ViewRender tool. Please see the macro
below...

The problem lies with the statement $render.eval("$e.$text")

Here $e is an object and $text contains a string value that is a property of
the object.

Some how the tool is  not able to return the value of the object property. I
am I missing something here....


#macro (selectcontrol $name $selected $list $id $text)
	#set($s="NULL" )
	#set($s=$selected )
	<select name="$name">
	#foreach ($e in $list )
	#set($v = $render.eval("$e.$id"))
	<option value="$v"#if("$v"=="$s")
selected="selected"#end>$render.eval("$e.$text")</option>
	#end
	</select>
#end

Regards...
Binu Nadesan.
(513) 612-2206.



unsubscribe john@rothfield.com and john@sfhypnosis.com PLEASE

Posted by John Rothfield <jo...@rothfield.com>.

Shinobu Kawai wrote:
> Hi Binu,
> 
> 
>>I have problem with the Velocity ViewRender tool. Please see the macro
>>below...
>>
>>The problem lies with the statement $render.eval("$e.$text")
>>
>>Here $e is an object and $text contains a string value that is a property of
>>the object.
> 
> 
> Let's say that "foo" was the value of $text.  What you really want to
> do is $render.eval("$e.foo").  You can either make such a variable and
> pass it to $render.eval(), or you can use $render.recurse() to get the
> result.
> 
> The first one works something like this:
> #set($D = "$")
> #set($getText = "${D}e.$text")
> $render.eval($getText)
> 
> and the second like this:
> #set($D = "$")
> $render.recurse("${D}e.$text")
> 
> Of course, if the result contains VTL-ish stuff, you'll have to use
> the first one because recurse() will keep on evaluating it.
> 
> Best regards,
> -- Shinobu Kawai
> 
> --
> Shinobu Kawai <sh...@gmail.com>
> 
> ---------------------------------------------------------------------
> 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


Re: Problems with ViewRenderTool

Posted by Shinobu Kawai <sh...@gmail.com>.
Hi Binu,

> I have problem with the Velocity ViewRender tool. Please see the macro
> below...
> 
> The problem lies with the statement $render.eval("$e.$text")
> 
> Here $e is an object and $text contains a string value that is a property of
> the object.

Let's say that "foo" was the value of $text.  What you really want to
do is $render.eval("$e.foo").  You can either make such a variable and
pass it to $render.eval(), or you can use $render.recurse() to get the
result.

The first one works something like this:
#set($D = "$")
#set($getText = "${D}e.$text")
$render.eval($getText)

and the second like this:
#set($D = "$")
$render.recurse("${D}e.$text")

Of course, if the result contains VTL-ish stuff, you'll have to use
the first one because recurse() will keep on evaluating it.

Best regards,
-- Shinobu Kawai

--
Shinobu Kawai <sh...@gmail.com>

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


Re: Problems with ViewRenderTool

Posted by Claude Brisson <cl...@renegat.net>.
On Fri, 2004-12-10 at 22:14, Nadesan, Binu wrote:

> The problem lies with the statement $render.eval("$e.$text")
> 
> Here $e is an object and $text contains a string value that is a property of
> the object.
> 

try with :

$render.recurse("$e.$text")

because what you really want is eval(eval("$e.$text"))

Claude




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


Re: Problems with ViewRenderTool

Posted by Simon Christian <sj...@xtian.org.uk>.
Hi Binu,

I think the problem is that the parsers is trying to evaluate "$e.$text" 
all in one go. The documentation suggests encapsulating the varriables 
i.e. $render.eval( "${e}.${text}" )

http://jakarta.apache.org/velocity/tools/view/ViewRenderTool.html#eval()

Never actually used this particular 'tool myself, but I think that 
should solve the problem.

- simon

Nadesan, Binu wrote:
> Hi All,
> 
> I have problem with the Velocity ViewRender tool. Please see the macro
> below...
> 
> The problem lies with the statement $render.eval("$e.$text")
> 
> Here $e is an object and $text contains a string value that is a property of
> the object.
> 
> Some how the tool is  not able to return the value of the object property. I
> am I missing something here....
> 
> 
> #macro (selectcontrol $name $selected $list $id $text)
> 	#set($s="NULL" )
> 	#set($s=$selected )
> 	<select name="$name">
> 	#foreach ($e in $list )
> 	#set($v = $render.eval("$e.$id"))
> 	<option value="$v"#if("$v"=="$s")
> selected="selected"#end>$render.eval("$e.$text")</option>
> 	#end
> 	</select>
> #end
> 
> Regards...
> Binu Nadesan.
> (513) 612-2206.
> 
> 
> 


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