I have a form designed in jsni, now i want that form entries to be inserted in database on button click like we do in normal java code of gwt using RPC greeting service bridge, greeting service implementation of server side and greeting service Asynchronous. Is it possible to handle on sucess and on failure,on jsni button event.
1 Answers
0
votes
Of course it is possible, just read the GWT_Jsni documentation about how to use java stuff from js and viceversa. Export a java method using jsni, then when you have the form data, call that java method from js to send that data to the server, when you receive the callback, use jsni to call js.
[EDITED]
Using GQuery you could do something like this, without having to write any JSNI line nor having to deal with GWT wrappers:
// Change this selector by the one which matches your elements
GQuery.$("form input").each(new Function() {
public void f() {
String name = $(this).attr("name");
String value = $(this).val();
// Do something with name and value (RPC, databinding, etc)
}
});
NOTE: Than GQuery has nothing in common with jQuery but its API. It is enterelly written in GWT, so as you only will get compiled the code you use, and it does not load jQuery nor any external library.