Saturday, April 9, 2011

Request data problem with GWT

Hi,

I'm new on Django and GWT. I wrote simple application like this;

__views.py__
def reply(request):
return HttpResponse("Server reply:"+request.POST["data"])

__example.java__
String url = "django-server";
final RequestBuilder builder = new
RequestBuilder(RequestBuilder.POST, URL.encode(url));
builder.setHeader("Content-type", "application/x-www-form-
urlencoded");

.....

button.addClickHandler(new ClickHandler() {

@Override
public void onClick(ClickEvent event) {
try {
@SuppressWarnings({ "unused", "deprecation" })
Request request =
builder.sendRequest("data="+URL.encodeComponent("my string data"), new
RequestCallback() {
....

When I send POST data, I see my data on Firebug like this;

Parameters application/x-www-form-urlencoded
data my string data

Source
data=my+string+data

But response key error.

MultiValueDictKeyError at /
"Key 'data' not found in <QueryDict: {}>"


I've tried to use request.raw_post_data, but this also empty.

So how can i send my data to django from GWT app?

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

No comments:

Post a Comment