GWT ListBox with HasValue and @UiTemplate

1.3k Views Asked by At

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 ;
}
1

There are 1 best solutions below

2
On

You cannot cast ListBox to SelectOneListBox ("this new ListBox"), because ListBox is not an implementation of SelectOneListBox. Unlsee you have reference to ListBox, but in fact you keep SelectOneListBox in it. However I doubt it, because then your code should work.

Show us some code if you want to help us help you.