Thursday, December 22, 2011

firing httprequest multiple times

Hi

I have popup panel and it contains 1 hyper link, clicking on hyperlink
i am sending http post request to jsp / servlet in the handler
function of hyperlink.

the problem i am facing is described below,

step 1. suppose i click on hyper link, it sends http post request, i
get the expected result.

step 2. after step 1, if i again click on hyper link 1, it sends 2
http post request at a time and it increases for every click on hyper
link.

once i refresh the page the count begins from 1.

how to over come step 2 behaviour and send only one http request for
every click.

below is the code sample.

hyplink.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
// TODO Auto-generated method stub
String url = "http://sample.com/some.jsp"
data = "name:name1"
RequestBuilder builder = new RequestBuilder(RequestBuilder.POST,
URL.encode(url));
builder.setHeader("Content-Type", "application/json");
try {
builder.sendRequest(data, new RequestCallback() {
public void onError(Request request, Throwable exception) {
Window.alert("Request Builder Failed");
}
public void onResponseReceived(Request request, Response response)
{
Window.alert("Request Builder succeeded");
}
});
}
catch (RequestException e) {

e.printStackTrace();
}
}
});

NOTE: if sample code contains any syntax error ignore it, every thing
is working fine in actual code.

Thanks
karun

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment