2013-12-10 43 views
0

我們在創建,保存和更新應用程序中的憑證成功完成後顯示消息,我們使用gwt完成上述所有處理,並使用gwt-rpc從服務器端獲得成功消息,然後將該消息在gwt入口點聲明的面板中。我們決定使用gwt-query來使應用程序有效,就像我們向用戶顯示消息後,應該在一段時間(秒)後隱藏它。如何對gwt入口點中聲明的元素應用gwt-query?

我們已經嘗試過了,但是我們無法對在gwt入口點聲明的面板或元素應用gquery。我們申請了html或jsp文件中的元素。我們需要一些幫助。

代碼片斷

Public class myGwtEntryPoint implements EntryPoint { 
VerticalPanel fiscalSettingPanel = new VerticalPanel(); 
    AbsolutePanel messagePanel = new AbsolutePanel(); 
    SimplePanel finishPanel = new SimplePanel(); 
    BaseCurrency baseCurrencyGlobal; 
    ListBox monthListBox = new ListBox(); 

    @Override 
    public void onModuleLoad() { 
    // Removing loading image in Jsp before loading gwt module. 
    if (RootPanel.get("accountingsetup-div").getElement().hasChildNodes()) 
     RootPanel.get("accountingsetup-div").getElement().getFirstChildElement().removeFromParent(); 

     // Here i am getting success message from server(gwt-rpc) and that to the "messagePanel", that messagePanel to the 'fiscalSettingPanel ' 
     fiscalSettingPanel .add("messagePanel"); 
} 

在上面的代碼中,一旦顯示的消息,我想使用GWT查詢

+0

你用什麼CSS選擇器與Gquery? – spg

+0

我試着通過設置消息面板的ID。 – majji

+0

like'$(「#accountingsetup-div」)'?哈希符號在這裏很重要 – spg

回答

0

這樣做後5秒消息消失?

import com.google.gwt.user.client.Timer; 

private Timer myTimer = new Timer() 
{ 
    @Override 
    public void run() 
    { 
     /** 
     * remove your Panel 
     */ 
     fiscalSettingPanel.remove("messagePanel"); 
    } 
}; 
myTimer.schedule(5000); 
+0

ups,你的問題不是定時器/計時問題,你的問題是用gwtquery選擇messagePanel,還是不行? –

+0

是的,我想通過gwt-query來做到這一點 – majji

0

你可以在你的情況下使用gquery選擇和使用元素和部件進行交互,可以使用CSS選擇器,元件和部件的參數,所以

1 .-我會用gquery刪除以這種方式從JSP加載圖像,而不是處理大型代碼:

// Removing loading image in Jsp before loading gwt module. 
$("#accountingsetup-div").empty(); 

2:而隨着怎麼了一段時間後隱藏面板相關的,我會用特效隊列,所以鏈接的延遲和隱藏效果就足夠了。

// Here i am getting success message from server(gwt-rpc) and that to the "messagePanel", that messagePanel to the 'fiscalSettingPanel ' 

messagePanel.clear(); 
messagePanel.add(new Label("Server message")); 

// First show the panel, and them enqueue an effect to hide it 
$(messagePanel).show().delay(4000).fadeOut();