Quantcast
Channel: xCommunity : Popular Discussions - Discuss
Viewing all articles
Browse latest Browse all 932

format() - empty string rendered as "null"

$
0
0

I'm rendering various details from an event in html along the lines of the default integration, but some of them have been coming out as the string "null". If my event XML includes values it's fine, but sometime the providing application sends tags with empty content:

<bridge_extension type='string'></bridge_extension><bridge_conf_id   type='string'></bridge_conf_id>

 

After trying many combinations of tests for EXISTS, comparison to null and "", and checking::length() > 0, it turned out that the format() function is converting an empty string parameter to the string "null" - also, comparing to "" doesn't behave as expected to provide a guard against this. Coded as

 

IF (EXISTS($event.bridge_conf_id) && $event.bridge_conf_id != "")  $rowBridgeConfId = format($tablerow_t, 7, "Bridge conference ID", $event.bridge_conf_id)  $eventinfo::concat($rowBridgeConfId)
... etc

 

I get html output like this:

format-empty-string-null.png

This is contrary to the behaviour of the underlying Java class MessageFormat, which only renders a genuinely null parameter as "null".

 

On the handling of the string object comparisons, I added some basic individual tests at the top of the script, and saw these results:

 

bridge_conf_id EXISTS
bridge_conf_id != null
bridge_conf_id != empty-string
bridge_conf_id::length==0
bridge_conf_id is
Interpreter Runs:   $formatted = format("[row {0} tag {1} value {2}]", 7, "Bridge conference ID", $event.bridge_conf_id)
bridge_conf_id formatted is [row 7 tag Bridge conference ID value null]

 

Shouldn't a test ($event.some_param != "") work?


Viewing all articles
Browse latest Browse all 932

Trending Articles