Left side (xx) of 'y' operation has null value. Operation not possible

Left side (xx) of 'y' operation has null value. Operation not possible

I have been seeing a lot of messages like this in my dotCMS logs:
?
1
2
[18/10/10 02:19:45:045 EST] ERROR app.VelocityEngine: Left side ($queryType) of '==' operation has null value. Operation not possible. /usr/local/dotcms/webap
ps/../dotCMS/assets/1/4/14777.vtl [line 5, column 25]

This results from code such as:
?
1
#if ($queryType == "$expectedValue" )

I thought this was strange because the macro this code belonged to wasn't even being executed - so the variable never gets a value anyway. It turns out the fix is to quote the variable, as per below.
?
1
#if ("$queryType" == "$expectedValue" )

That's fine for string values, but won't stop an error on anything involved in a numerical operation.
?
1
#if ($totalResults > 0 )

The above code results in this error:

?
1
2
[18/10/10 02:46:43:043 EST] ERROR app.VelocityEngine: Left side ($totalResults) of '>' operation has null value. Operation not possible. /usr/local/dotcms/webap
ps/../dotCMS/assets/1/4/14777.vtl [line 1, column 24]

The fix is to make sure it is a number under any circumstances.

?
1
2
3
4
#if (!$UtilMethods.isSet($totalResults))
#set($totalResults = 0)
#end
#if ($totalResults > 0 )


It seems Velocity is a bit like bash or DOS shell scripts in this respect; unless you quote a variable name, it will see null as the value and output an error.

My dotCMS notes.

http://robertmarkbramprogrammer.blogspot.com/2010/10/left-side-xx-of-y-operation-has-null.html
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值