Hi,

your question is not clear. You seem to be familiar with some other programming 
or scripting language - please get up-to-date with Java for the application 
side, also look at the examples in the Velocity developers guide:
  http://velocity.apache.org/engine/releases/velocity-1.6.2/developer-guide.html
and Velocity syntax for the template side; read the Velocity users guide:
  http://velocity.apache.org/engine/releases/velocity-1.6.2/user-guide.html

If your function is part of a Java class, place an instance into the Velocity 
context either with the ToolboxManager or using Java code in your application 
before merging:
  context.put("Functions", new Function());
(more at: 
http://velocity.apache.org/engine/releases/velocity-1.6.2/developer-guide.html#How_Velocity_Works
 )
and use it in your template:
  #set( $retvalue = $Functions.function() )

If you want to define scripted code in your Velocity template (called macros), 
you can do:
  #macro( Function )
   ...do something wise
  #end
and use it in your template:
  #set( $retvalue = "#Function()" )
Please note that macros can only return strings! So if you need variant return 
types, you need a Java class with a corresponding method (in which case a 
"void" parameter does not make sense - how will it differentiate what to 
return?).

Hope this helped,
Christoph

bren36 wrote:
> Hi
> 
> I have the following scenario 
> 
>   string retvlaue = Function (void)

:I There are no void pass-in parameters in Java.

> 
> How can i  script this inside velocity ????


> -------- Original Message --------
> Subject: return value
> Date: Thu, 16 Apr 2009 12:14:12 -0700 (PDT)
> From: bren36 <[email protected]>
> Reply-To: Velocity Users List <[email protected]>
> To: [email protected]
> 
> 
> Hi ,
> 
> Want to achieve the following using  vm get a return value from a  function
> - the return value can be a structure /integer /string  type .
> 
> eg .
> 
> temp FUNCTION_call ()
> 
> Anyone have any ideas how i can achieve  this in.vm ?


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to