1
我已經存儲在Load上的值,之後,我改變了部件屬性,再次卸載之前我想設置以前存儲的值,我該怎麼辦? widget.addAttachHandler(EventHandler)對我很有幫助。如何在GWT中的當前視圖(onUnLoad)之前設置以前的值?
我已經存儲在Load上的值,之後,我改變了部件屬性,再次卸載之前我想設置以前存儲的值,我該怎麼辦? widget.addAttachHandler(EventHandler)對我很有幫助。如何在GWT中的當前視圖(onUnLoad)之前設置以前的值?
只是帶有事件監聽器的design your own widget。並在您的自定義小部件類ovveride中加載和卸載方法。
// This method is called when a widget is attached to the browser's document
@Override
protected void onLoad() {
setEventListener(inputElem, this);
// ...
}
// This method is called when a widget is detached from the browser's document
@Override protected void onUnload() {
// Clear out the inputElem's event listener (breaking the circular
// reference between it and the widget); avoid memory leaks
setEventListener(inputElem, null);
// ...
}
爲什麼你會混淆事件監聽器來存儲值?這個工作已經由'onAttach'完成了,它調用onLoad(和'onDetach',它調用'onUnload')。 –