带有 HasValue 和 @UiTemplate 的 GWT 列表框
我正在尝试使用 ListBox
实现 HasValue
接口,我从以下链接获取了代码/想法,并制作了自己的列表框类
http://turbomanage.wordpress.com/2010/04/01/selectonelistbox- for-use-with-gwtmvp/
现在的问题是我在视图中使用 @UiTemplate
并且我发现很难将 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 ;
}
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 ;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您无法将
ListBox
转换为SelectOneListBox
(“这个新的ListBox
”),因为ListBox
不是SelectOneListBox
的实现代码>SelectOneListBox。除非您引用了ListBox
,但实际上您将SelectOneListBox
保留在其中。不过我对此表示怀疑,因为那样你的代码应该可以工作。如果您想帮助我们帮助您,请向我们展示一些代码。
You cannot cast
ListBox
toSelectOneListBox
("this newListBox
"), becauseListBox
is not an implementation ofSelectOneListBox
. Unlsee you have reference toListBox
, but in fact you keepSelectOneListBox
in it. However I doubt it, because then your code should work.Show us some code if you want to help us help you.