2013-12-11 66 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() 
相關問題