I am trying to use ListBox with HasValue interface implemented, I got code / idea from the following link and I made the my own list box class
http://turbomanage.wordpress.com/2010/04/01/selectonelistbox-for-use-with-gwtmvp/
Now the problem is I am using @UiTemplate in my Views and I am finding it difficult to cast ListBox to this new ListBox.
My View class code:
// 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 ;
}
You cannot cast
ListBoxtoSelectOneListBox("this newListBox"), becauseListBoxis not an implementation ofSelectOneListBox. Unlsee you have reference toListBox, but in fact you keepSelectOneListBoxin it. However I doubt it, because then your code should work.Show us some code if you want to help us help you.