我想画一个图表的基础上,从数据库检索的日期使用RPC。
但每次我都得不到结果。我的rpc函数正在工作。
我认为这是这个过程的顺序。
下面是我的类:
public class TrafficPattern_1 extends GChart {
TrafficPattern_1() {
final DBServiceAsync dbService = GWT
.create(DBService.class);
dbService.SendData(null, null,
new AsyncCallback<Container_TrafficPattern>() {
@Override
public void onFailure(Throwable caught) {
}
@Override
public void onSuccess(Container_TrafficPattern result) {
// TODO Auto-generated method stub
pContainer.SetaDate(result.aDate.get(1));
}
});
pContainer.aDate.get(0);
setChartSize(350, 200);
setChartTitle("<h2>Temperature vs Time<h2>");
setPadding("8px");
//setPixelSize(380, 200);
getXAxis().setAxisLabel("<small><b><i>Time</i></b></small>");
getXAxis().setHasGridlines(true);
getXAxis().setTickCount(6);
// Except for "=(Date)", a standard GWT DateTimeFormat string
getXAxis().setTickLabelFormat("=(Date)h:mm a");
getYAxis().setAxisLabel("<small><b><i>°C</i></b></small>");
getYAxis().setHasGridlines(true);
getYAxis().setTickCount(11);
getYAxis().setAxisMin(11);
getYAxis().setAxisMax(16);
addCurve();
getCurve().setLegendLabel("<i> </i>");
getCurve().getSymbol().setBorderColor("blue");
getCurve().getSymbol().setBackgroundColor("blue");
// getCurve().getSymbol().setFillSpacing(10);
// getCurve().getSymbol().setFillThickness(3);
getCurve().getSymbol().setSymbolType(SymbolType.LINE);
getCurve().getSymbol().setFillThickness(2);
getCurve().getSymbol().setFillSpacing(1);
for (int i = 0; i < dateSequence.length; i++)
// Note that getTime() returns milliseconds since
// 1/1/70--required whenever "date cast" tick label
// formats (those beginning with "=(Date)") are used.
getCurve().addPoint(dateSequence[i].date.getTime(),
dateSequence[i].value);
}发布于 2010-03-26 06:24:48
由于GWT RPC是异步的,您不知道它是否或何时会成功。而且与您的代码更相关,因为GWT是一种异步回调机制,它与线性意义上的同步或过程执行不同,"pContainer.SetaDate(result.aDate.get(1));“将在"pContainer.aDate.get(0);”之前执行,而不是在成功回调的pContainer上设置date属性,而是将其作为参数传递给生成图表内容的新方法。只需将回调后的所有内容重构为这个新方法,并在成功时调用它,将日期作为arg传递给它。
https://stackoverflow.com/questions/2198902
复制相似问题