I guess that is what you want (in a pull tool):

 public String eval(String vtl, RunData data) throws Exception
    {
        StringWriter sw = new StringWriter();
        boolean      success =
Velocity.evaluate(TurbineVelocity.getContext(data), sw, "", vtl);

        if (success)
        {
            return sw.toString();
        }

        return null;
    }

Am Mon, den 16.02.2004 schrieb Gerry Duprey um 22:10:
> Howdy All,
> 
> I realize this is more a velocity question, but the velocity email list is 
> shared with the jakarta commons list and doesn't seem to have much velocity 
> traffic on it.
> 
> What I'm trying to do is create a velocity macro that can define an input 
> field using a fixed name for the field and have that macro have provisions for 
> default values for the field based on the fields fixed name.  For example, I'd 
> love to do something like
> 
> #macro ( myInput $fieldName )
>    <INPUT TYPE="TEXT" NAME="FLD_$fieldName" VALUE="$!{VALUE_${fieldName}}">
> #end
> 
> so
> 
> #myInput ( "UserName" )
> 
> becomes
> 
>    <INPUT TYPE="TEXT" NAME="FLD_UserName" VALUE="Gerry">
> 
> Assuming my Context has a symbol called VALUE_UserName in it set to the string 
> "Gerry" (i.e. context.put("VALUE_UserName", "Gerry")).
> 
> In short, the ability to have an interpreted reference/variable name.
> 
> It would also let me do things like having macros that knew how to display 
> errors attached to fields automatically.  Consider:
> 
> #macro ( myInput $fieldName )
>    <INPUT TYPE="TEXT" NAME="FLD_$fieldName" VALUE="$!{VALUE_${fieldName}}">
>    #if ( ${ERROR_${fieldName}} )
>      <FONT COLOR="red">* ${ERROR_${fieldName}}</FONT>
>    #end
> #end
> 
> This gives my verification routines a great deal of flexibility and allows 
> very generic forms processing modules.
> 
> Any thoughts (on how to do this or if you think I'm bonkers, that is :-)?
> 
> Gerry


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to