2013-12-11 67 views
0

我需要一些属性设置,需要设置,将被发送到我的日期选择器。为什么评估函数将String设置为“false”而不是布尔false?

对于某些未知的changeMonth & changeYear的默认值没有被正确设置,它们返回false作为字符串。

我知道properties.changemonth是空的,所以它应该返回布尔值假,我设置为默认值。

任何人有任何想法,为什么它不工作?提前致谢。

 $("#test-my-component-datepicker").datePicker({ 
      'dateFormat': "${not empty properties.dateformat ? properties.dateformat : 'dd/mm/yy'}", 
      'showOn': "${not empty properties.showcalendar && properties.showcalendar ? 'button' : ''}", 
      'buttonImage': "${not empty properties.showcalendar && properties.showcalendar ? properties.imagecalendar : ''}", 
      'buttonImageOnly': "${not empty properties.showcalendar && properties.showcalendar ? properties.showbuttononly : ''}", 
      'changeMonth': "${not empty properties.changemonth ? properties.changemonth : false}", 
      'changeYear': "${not empty properties.changeyear ? properties.changeyear : false}", 
      'showButtonPanel': false,     
      'showOtherMonths': true, 
      'selectOtherMonths': true 
    }); 

回答

1
  • 是一个字符串操作者(或至少操作者的物体,其具有.isEmpty()方法)
  • expresison的结果是引用,所以任何它被 - 它被转换为字符串通过toString()

空:空操作符是一个前缀操作,可用于确定值是空还是空。

"${not empty properties.changemonth ? properties.changemonth : false}" 
"${not empty String ? String : boolean}" 
"${String}" or "${boolean}" 
"String" or "boolean" 
String or Boolean.valueOf(boolean).toString() 
相关问题