0

I am using the GWT application widget library and want to validate the controls in the button click event.The code I am writing

 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.

user229044
  • 232,980
  • 40
  • 330
  • 338
Amandeep Singh
  • 3,754
  • 8
  • 51
  • 72

2 Answers2

1

the widgets() method returns a list of widget and not a 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 :

PasswordTextBox myPasswordInput = $(e).filter("input[type='password']").widget();

Question: are you sure of your '$(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"

If you want to retrieve all password inputs present within an element e, you have to use :

List<Widget> myPasswordInputs = $("input[type='password']",e).widgets();

Julien

jdramaix
  • 1,104
  • 6
  • 9
  • Hi Julien, There is no method as widget() or widgets that I am able to use, as this methods when I am writing giving me compile time error.Can you please suggest me where I can get the tutorial accessing my controls such as TextBox,label of com.google.gwt.user.client.ui.* package in GQuery.Any help from your side would really help me to complete my assignment.Thanks, Amandeep – Amandeep Singh May 27 '11 at 09:19
  • If you don't have a widgets() or widget() method, it is because you'are still using an old snapshot jar. Take the last stable should resolve your problems ! – jdramaix May 27 '11 at 10:43
  • this part of the gwtquery user guide can help you : http://code.google.com/p/gwtquery/wiki/GettingStarted#Manipulating_your_widgets – jdramaix May 27 '11 at 10:44
  • Wouldn't you know how to append a GWT widget using GQuery in one line, please? http://stackoverflow.com/q/37687169/224239 – Jaroslav Záruba Jun 08 '16 at 05:53
0

Try:

GQuery input = GQuery.$(e).filter("input[type='password']").widgets();

You need to do a static import to use $ directly:

import static com.google.gwt.query.client.GQuery.*;
import static com.google.gwt.query.client.css.CSS.*;
Peter Knego
  • 79,991
  • 11
  • 123
  • 154
  • Thanks @Peter Knego, When I am importing the above libraries it is giving me error while I am building my application,the error is [ERROR] Unexpected \path\build-gwt.xml:262: The following error occurred while executing this line: path\build-gwt.xml:411: Java returned: I think the error is in setting the classpath somewhere,Please help.. – Amandeep Singh May 27 '11 at 05:34
  • Peter:When I am importing the above packages I am getting the build error.Please tell me how I can set my build.xml to use the gquery jar file.I am also inheriting the module required for it. Thanks,Amandeep – Amandeep Singh May 27 '11 at 05:42
  • Try following this: http://code.google.com/p/gwtquery/wiki/GettingStarted#Setting_up_a_project – Peter Knego May 27 '11 at 06:10
  • Thanks Peter, I am using netbeans and the the build.xml file it is creating is different from what created from command prompt which is given in that link.Can you please tell me what changes I need to make in the build.xml file which is created from netbeans.Please tell me where I can get the configuration o0f GQuery in netbeans. – Amandeep Singh May 27 '11 at 06:49
  • I don't use netbeans so I wouldn't know. Try this http://www.jondev.net/articles/Adding_external_JARs_to_Android_Projects_in_Netbeans_(nbandroid_-_kenai) – Peter Knego May 27 '11 at 06:52
  • Ok,but the link you provided here redirects to page which does not exist,please recheck the URL you mentioned above.Thanks for your concern once again. – Amandeep Singh May 27 '11 at 06:57
  • Yeah, the closing brace is removed from comments: `http://www.jondev.net/articles/Adding_external_JARs_to_Android_Projects_in_Netbeans_(nbandroid_-_kenai)` – Peter Knego May 27 '11 at 07:09