Uploaded image for project: 'XWiki Commons'
  1. XWiki Commons
  2. XCOMMONS-1866

Add a Velocity directive that tests for null

    XMLWordPrintable

Details

    • Improvement
    • Resolution: Won't Fix
    • Major
    • None
    • 12.0-rc-1
    • Velocity
    • None
    • Unknown
    • N/A
    • N/A

    Description

      It's not always easy with Velocity to check for null. You can use some tricks such as "#if ($variable == $NULL)" or "#if (!$variable)". However Velocity performs some conversions, calling methods such as getAsBoolean() or getAsString(). There are cases when you don't want them to be called as they can clash with your own implementation (note: this is the case for JsonObject from gson for ex).

      If you need to check only for null, this directive is probably the best for that.

      Attachments

        Activity

          People

            vmassol Vincent Massol
            vmassol Vincent Massol
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: