如何通过它的名字在gwt中获得文本框 [英] How to get a textbox by its name in gwt

查看:192
本文介绍了如何通过它的名字在gwt中获得文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以说我有一个有多个文本框的布局面板。



现在我想通过它的名称在该面板中获得特定的文本框。我该怎么做?



预先感谢。

一种方法是在创建时将文本框的引用保留在hashMap中。
尽管如此,您仍然需要小心内存泄漏。
另一种方法是使用 GWtQuery 。您可以通过名称访问DOM中的任何元素。



为了在没有GWTQuery的情况下获得它,您可以这样做:

 元素元素= Document.get()。getElementById(myTextboxID); 
TextBox box = new TextBox();
box.wrap(element);


Lets say I have a layout panel having multiple textboxes.

Now I want to get a particular textbox in that panel by its name. How can I do that?

Thanks in advance.

解决方案

One way to do it is to keep references of the textboxes in a hashMap while you create them. You need to be careful about memory leaks though. Another way is to use GWtQuery. You could access then by name any element in the DOM.

To get it without without GWTQuery you can do that:

Element element = Document.get().getElementById("myTextboxID");
TextBox box = new TextBox();
box.wrap(element);

这篇关于如何通过它的名字在gwt中获得文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆