把 上面的 改了
用gwt制作ajax浏览器
package chenmin.client;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.ClickListener;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.Widget;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.HTTPRequest;
import com.google.gwt.user.client.ResponseTextHandler;
/** *//**
* Entry point classes define <code>onModuleLoad()</code>.
*/
public class Http implements EntryPoint ...{

/** *//**
* This is the entry point method.
*/
public void onModuleLoad() ...{
final Button button = new Button("Click me");
final Label label = new Label();
final TextBox url = new TextBox();

button.addClickListener(new ClickListener() ...{
public void onClick(Widget sender) ...{
HTTPRequest.asyncPost(url.getText(),null, new ResponseTextHandler() ...{

public void onCompletion(String responseText) ...{
// TODO Auto-generated method stub
label.setText(responseText);
// xmlFile=responseText;
}
});
}
}
);
// Assume that the host HTML has elements defined whose
// IDs are "slot1", "slot2". In a real app, you probably would not want
// to hard-code IDs. Instead, you could, for example, search for all
// elements with a particular CSS class and replace them with widgets.
//
RootPanel.get("slot1").add(url);
RootPanel.get("slot2").add(button);
RootPanel.get().add(label);
}
}
本文介绍了一个使用GWT框架创建的简单AJAX应用程序实例。该应用通过按钮触发HTTP请求,并将响应结果显示在一个标签中。文章展示了如何设置基本的用户界面元素及处理异步请求。

1560

被折叠的 条评论
为什么被折叠?



