/*
* apparently. Ok, make one..
*/
VelocimacroProxy vp =
(VelocimacroProxy) Runtime.getVelocimacro( vmName, namespace );
if ( vp == null )
{
Runtime.error( "Velocity.invokeVelocimacro() : VM '"
+ vmName
+ "' : severe error. Unable to get VM from factory.");
return false;
}
/*
* if we get enough args?
*/
if ( vp.getNumArgs() > params.length )
{
Runtime.error( "Velocity.invokeVelocimacro() : VM '"
+ vmName + "' : invalid # of args. Needed "
+ vp.getNumArgs()
+ " but called with " + params.length);
return false;
}
/*
* ok. setup the vm
*/
/*
* fix the parms : since we don't require the $ from the caller,
* we need to add it
*/
int [] types = new int[vp.getNumArgs()];
String[] p = new String[vp.getNumArgs()];
for( int i = 0; i < types.length; i++)
{
types[i] = ParserTreeConstants.JJTREFERENCE;
p[i] = "$" + params[i];
}
vp.setupMacro( p, types );
try
{
InternalContextAdapterImpl ica
= new InternalContextAdapterImpl( context );
try
{
ica.pushCurrentTemplateName( namespace );
vp.render( ica, writer, null);
}
finally
{
ica.popCurrentTemplateName();
}