2013-05-06 40 views
0

如何從ListView中獲取選定的項目形式DropDownChoice?Wicket - 使用Scala獲取DropDownChoice中的選定項目

我實現了矮胖代碼波紋管:

val listCustomer: java.util.List[Customer] = customerDAO.listCustomers 

item.add(new DropDownChoice("customerSelection", listCustomer, new ChoiceRenderer[Customer]("name"))) 

在這種情況下,我想要得到的模型需求的顯示名稱屬性。

感謝

回答

1

試試這個:

new DropDownChoice[Customer](("customerSelection", new Model[Customer], listCustomer, new ChoiceRenderer[Customer]("name"))) { 
    protected override def wantOnSelectionChangedNotifications: Boolean = true 

    protected override def onSelectionChanged(newSelection: Customer) { 
    super.onSelectionChanged(newSelection) 
    } 
} 
+0

非常感謝@Alexey,我改變了代碼爲這個新DropDownChoice [客戶](( 「customerSelection」,新PropertyModel(客戶, 「名」) ...等等,我得到的錯誤java.lang.ClassCastException:java.lang.String不能轉換爲com.sys.entities.Customer你能告訴我我做錯了什麼? – Bera 2013-05-09 03:18:56

相關問題