silent notation

Aug 18, 2009 at 6:38 PM
Edited Aug 18, 2009 at 6:40 PM

I notice that when I use silent notation to write out a null value, I'm still seeing errors being logged.  Would expect it to write an empty string without trying to do any error handling, right? i.e.

 

VelocityContext velocityContext = new VelocityContext(toolsContext);
velocityContext.Put("pants", null);

 

Then in my template:

 

## shirt is never defined in the velocityContext
$!shirt

 

We're using some custom error handling code.  Maybe that's overriding something?

 

    class InvalidReferenceHandler : IInvalidReferenceEventHandler {
		private static Log4NetLogChute logger = new Log4NetLogChute();
        // This handler throws an exception if a reference defined in a template is invalid
        // (object or property does not exist in the context).  If it is just a null property value,
        // it just returns the null value, since this can be a normal data condition, as opposed to 
        // an issue with the template or context.
        #region Implementation of IInvalidReferenceEventHandler
        public object InvalidGetMethod(IContext context, string reference, object obj, string property, Info info)
        {
            string error = String.Format("Invalid Get reference found in Template {0} at line {1}, column {2}: {3}", info.TemplateName, info.Line, info.Column, reference);
			logger.Log(LogChute_Fields.ERROR_ID, error);
            return null;
        }

        public bool InvalidSetMethod(IContext context, string leftreference, string rightreference, Info info)
        {
            string error = String.Format("Invalid Set reference found in Template {0} at line {1}, column {2}: LHS: {3} RHS: {4}", info.TemplateName, info.Line, info.Column, leftreference, rightreference);
			logger.Log(LogChute_Fields.ERROR_ID, error);
			return false;
        }

        public object InvalidMethod(IContext context, string reference, object object_Renamed, string method, Info info)
        {
            string error = String.Format("Invalid Method reference found in Template {0} at line {1}, column {2}: {3}", info.TemplateName, info.Line, info.Column, method);
			logger.Log(LogChute_Fields.ERROR_ID, error);
			return null;
        }

        #endregion
    }

The InvalidGetMethod handler shouldn't be getting called, right?