Update... I am constructing my VelocityContext by handing it new HashMap(request.getParameterMap()) so as to allow request parameters to be treated like request scoped variables and allow them to seamlessly 'flow through' a request. I was having a problem as $paramName was outputting an array toString rather than the actual parameter. So I constructed a ReferenceInsertionEventHandler, which fixed that problem.

Turns out this is just a bit daft, because now a simple #if against a literal parameter will fail. If I hit "?apples=yummy" and on my template I have:

#if( $apples == 'yummy' )
Apples are yummy.
#else
I am daft.
#end

I will always be reminded that sometimes poking at a hornets' nest stings you. In this case I assume that since $apples is a String[] instead of a String, that the #if is failing because it doesn't use ReferenceInsertionEventHandler to obtain the value of a variable in order to test against-- only to output.

Back to the drawing board. Was hoping to make this 'efficient' by simply wrapping the raw parameter map, but it's looking like it'll be safer just to give up this angle of attack. :-)

Jason Pettiss
[EMAIL PROTECTED]


Jason Pettiss wrote:

Amazing.  Awesome.  Exactly what I need.

class ReferenceInserter
   implements ReferenceInsertionEventHandler
{
   public Object referenceInsert(
       String reference,
       Object value)
   {
       if (value instanceof Object[])
       {
           Object[] a = (Object[])value;
           if (a.length>0) value = a[0];
       }
       return value;
   }   }

I love velocity.  :-)

Thanks,

Jason Pettiss
[EMAIL PROTECTED]



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

Reply via email to