code: protected Boolean checkBoolean(Object val, Boolean def) {
          return (val == null) ? def : (Boolean) val;
      }
docs: Checks a returned Javascript value where we expect a boolean but could
  get null.
  
  @param val The value from Javascript to be checked.
  @param def The default return value, which can be null.
  @return The actual value, or if null, returns false.