|
開fa过ext-js,smartgwt的同學是不是有點gan觉和HTML绝緣了,qishi本质上來说gwt程序也是javascript程序,所以两者之間ke以集成在一起。you些功能用javascript编寫方便,有些用java方便。
下面的演示程序是:gwt,yui,和一個显示圖片的light-box(prototype)插件Dehun合。
这是演示程xu: http://trade.fh.gov.cn/oa/Fhtrade.html
Java代码
public final native void loadScripts(ExportedNatives en,JsArrayString scriptUrls,String scriptsName,String indicatorStr)/*-{
en.@com.m3958.company.fhtrade.client.nativemethods.ExportedNatives::showIndicator(Ljava/lang/String;)(indicatorStr);
$wnd.Y.Get.script(scriptUrls,
{
onSuccess: function(o) {
en.@com.m3958.company.fhtrade.client.nativemethods.ExportedNatives::scriptLoadResult(Ljava/lang/String;Z)(script2sName,true);
en.@com.m3958.company.fhtrade.client.nativemethods.ExportedNatives::hideIndicator()();
},
onFailure: function(o) {
en.@com.m3958.company.fhtrade.client.nativemethods.ExportedNatives::scriptLoadResult(Ljava/lang/String;Z)(scriptsName,false);
en.@com.m3958.company.fhtrade.client.nativemethods.ExportedNatives::hideIndicator()();
$wnd.Y.log("transaction failed");
},
onTimeout: function(o) {
en.@com.m3958.company.fhtrade.client.nativemethods.ExportedNatives::scriptLoadResult(Ljava/lang/String;Z)(scriptsName,false);
en.@com.m3958.company.fhtrade.client.nativemethods.ExportedNatives::hideIndicator()();
$wnd.Y.log("transaction timed out");
},
data: "foo",
timeout: 10000, // 10 second timeout
context: $wnd//, // make the YUI instance
// win: otherframe // target another window/frame
//autopurge: true // allow the utility to choose when to
// remove the nodes
//purgetheshold: 1 // purge previous transaction before
// next transaction
});
}-*/;
public final native void loadCss(ExportedNatives en,JsArrayString cssUrls,String csssName,String indicatorStr)/*-{
en.@com.m3958.company.fhtrade.client.nativemethods.ExportedNatives::showIndicator(Ljava/lang/String;)(indicatorStr);
$wnd.Y.Get.css(cssUrls,
{
onSuccess: function(o) {
en.@com.m3958.company.fhtrade.client.nativemethods.ExportedNatives::hideIndicator()();
en.@com.m3958.company.fhtrade.client.nativemethods.ExportedNatives::scriptLoadResult(Ljava/lang/String;Z)(csssName,true);
},
onFailure: function(o) {
en.@com.m3958.company.fhtrade.client.nativemethods.ExportedNatives::scriptLoadResult(Ljava/lang/String;Z)(csssName,false);
en.@com.m3958.company.fhtrade.client.nativemethods.ExportedNatives::hideIndicator()();
$wnd.Y.log("transaction failed");
},
onTimeout: function(o) {
en.@com.m3958.company.fhtrade.client.nativemethods.ExportedNatives::scriptLoadResult(Ljava/lang/String;Z)(csssName,false);
en.@com.m3958.company.fhtrade.client.nativemethods.ExportedNatives::hideIndicator()();
$wnd.Y.log("transaction timed out");
},
data: "foo",
timeout: 10000, // 10 second timeout
insertBefore:'styleoverride'
});
}-*/;
2 public final native void loadScripts(ExportedNatives en,JsArrayString scriptUrls,String scriptsName,String indicatorStr)/*-{
en.@com.m3958.company.fhtrade.client.nativemethods.ExportedNatives::showIndicator(Ljava/lang/String;)(indicatorStr);
$wnd.Y.Get.script(scriptUrls,
{
onSuccess: function(o) {
en.@com.m3958.company.fhtrade.client.nativemethods.ExportedNatives::scriptLoadResult(Ljava/lang/String;Z)(scriptsName,true);
en.@com.m3958.company.fhtrade.client.nativemethods.ExportedNatives::hideIndicator()();
},
onFailure: function(o) {
en.@com.m3958.company.fhtrade.client.nativemethods.ExportedNatives::scriptLoadResult(Ljava/lang/String;Z)(scriptsName,false);
en.@com.m3958.company.fhtrade.client.nativemethods.ExportedNatives::hideIndicator()();
$wnd.Y.log("transaction failed");
},
onTimeout: function(o) {
en.@com.m3958.company.fhtrade.client.nativemethods.ExportedNatives::scriptLoadResult(Ljava/lang/String;Z)(scriptsName,false);
en.@com.m3958.company.fhtrade.client.nativemethods.ExportedNatives::hideIndicator()();
$wnd.Y.log("transaction timed out");
},
data: "foo",
timeout: 10000, // 10 second timeout
context: $wnd//, // make the YUI instance
// win: otherframe // target another window/frame
//autopurge: true // allow the utility to choose when to
// remove the nodes
//purgetheshold: 1 // purge previous transaction before
// next transaction
});
}-*/;
public final native void loadCss(ExportedNatives en,JsArrayString cssUrls,String csssName,String indicatorStr)/*-{
en.@com.m3958.company.fhtrade.client.nativemethods.ExportedNatives::showIndicator(Ljava/lang/String;)(indicatorStr);
$wnd.Y.Get.css(cssUrls,
{
onSuccess: function(o) {
en.@com.m3958.company.fhtrade.client.nativemethods.ExportedNatives::hideIndicator()();
en.@com.m3958.company.fhtrade.client.nativemethods.ExportedNatives::scriptLoadResult(Ljava/lang/String;Z)(csssName,true);
},
onFailure: function(o) {
en.@com.m3958.company.fhtrade.client.nativemethods.ExportedNatives::scriptLoadResult(Ljava/lang/String;Z)(csssName,false);
en.@com.m3958.company.fhtrade.client.nativemethods.ExportedNatives::hideIndicator()();
$wnd.Y.log("transaction failed");
},
onTimeout: function(o) {
en.@com.m3958.company.fhtrade.client.nativemethods.ExportedNatives::scriptLoadResult(Ljava/lang/String;Z)(csssName,false);
en.@com.m3958.company.fhtrade.client.nativemethods.ExportedNatives::hideIndicator()();
$wnd.Y.log("transaction timed out");
},
data: "foo",
timeout: 10000, // 10 second timeout
insertBefore:'styleoverride'
});
}-*/;
歡迎来到Java学xiZhe论坛,轉载请zhu明地址:http://www.javaxxz.com. |
|