[英]Using GQuery in GWT widgets
I am using the GWT application widget library and want to validate the controls in the button click event.The code I am writing我正在使用 GWT 应用程序小部件库,并希望验证按钮单击事件中的控件。我正在编写的代码
GQuery input = $(e).filter("input[type='password']").widgets();
but its is giving me compile time error.Please tell me or refer me any tutorial for validating the widget library controls.但它给了我编译时错误。请告诉我或向我推荐任何验证小部件库控件的教程。
the widgets() method returns a list of widget and not a GQuery object widgets() 方法返回一个小部件列表,而不是 GQuery object
List<Widget> myPasswordInputs = $(e).filter("input[type='password']").widgets();
If you are only one input of type password you can maybe use directly widget() method:如果您只是一种密码类型的输入,您可以直接使用 widget() 方法:
PasswordTextBox myPasswordInput = $(e).filter("input[type='password']").widget();
Question: are you sure of your '$(e).filter("input[type='password']")'?问题:你确定你的'$(e).filter("input[type='password']")'吗? Because it means: "Create a GQuery object containing my element 'e' and keep it only if 'e' is an input of type password"
因为它的意思是:“创建一个包含我的元素‘e’的 GQuery object,并且只有在‘e’是密码类型的输入时才保留它”
If you want to retrieve all password inputs present within an element e, you have to use:如果要检索元素 e 中存在的所有密码输入,则必须使用:
List<Widget> myPasswordInputs = $("input[type='password']",e).widgets();
Julien朱利安
Try:尝试:
GQuery input = GQuery.$(e).filter("input[type='password']").widgets();
You need to do a static import to use $
directly:您需要执行 static 导入才能直接使用
$
:
import static com.google.gwt.query.client.GQuery.*;
import static com.google.gwt.query.client.css.CSS.*;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.