2010-09-12 16 views
0

我想使用ListBox與實施HasValue接口,我從下面的鏈接代碼/想法,我做了我自己的列表框類GWT列表框用的HasValue和@UiTemplate

http://turbomanage.wordpress.com/2010/04/01/selectonelistbox-for-use-with-gwtmvp/

現在問題是我在我的視圖中使用@UiTemplate,我發現很難將ListBox投射到這個新的ListBox

我的視圖類代碼:

// defines List Box , so it get attached with UiTemplate 
@UiField ListBox countryListBox ; 

//-- this function should get the list box, i call this in presenter... 
//-- now the problem is i do not know how i take this listbox back as selectOneListBox 
public HasSelectedValue <T> getCountry() { 
     // TODO Auto-generated method stub 
     //return desTextBox; 
     SelectOneListBox<T> sel = new SelectOneListBox<T>(null); 
     sel =(SelectOneListBox<T>) countryListBox; 
     //return (SelectOneListBox<T>) countryListBox; 
     return sel; 
     //return countryListBox ; 
} 

回答

0

你不能投ListBoxSelectOneListBox( 「新ListBox」),因爲ListBox不是SelectOneListBox的實現。 Unlsee你有參考ListBox,但實際上你保持SelectOneListBox在裏面。不過,我懷疑它,因爲那時你的代碼應該工作。

如果您想幫助我們幫助您,請告訴我們一些代碼。

+0

我使用的SelectOneListBox在博客給出的,我想表明將在它的國家名單列表框,我試圖投它像之下,但它給了我異常 公共HasSelectedValue getCountry(){ \t SelectOneListBox sel = new SelectOneListBox (null); \t sel =(SelectOneListBox )countryListBox; \t // return(SelectOneListBox )countryListBox; \t return sel; \t // return countryListBox; } – 2010-09-12 15:56:16

+0

你能編輯你的問題並把你的代碼放在那裏嗎?它在評論中不可讀。 – amorfis 2010-09-12 16:10:26