2014-03-06 32 views
0

我正在使用GWTP。有如下來的OpenURL方法:爲什麼PlaceRequest無法正常工作(GWTP)?

public void openURL(int key){ 
    PlaceRequest request = new PlaceRequest(NameTokens.search).with("showData", "y"); 
    if(key==1){ 
     request.with("firstVariable","2154"); 
    } 
    else if(key==2){ 
     request.with("secondVariable","4454"); 
    } 
    String url = Window.Location.createUrlBuilder().setHash(placeManager.buildHistoryToken(request)).buildString(); 
    Window.open(url, "_blank", null); 
} 

有一個按鈕來調用openURL(1),點擊按鈕後,它以這種形式打開的網址:

abc.com#search;showData=y 

顯然上述網址缺少firstVariable PARAM部分。

正確的URL應該是

abc.com#search;showData=y;firstVariable=2154 

我不知道爲什麼GWTP沒讀過request.with("firstVariable","2154");一部分,因爲我們的預期。

你能找出解決方案嗎?

回答

2

request.with(PARAM,value)返回新PlaceRequest,所以

request = request.with("firstVariable","2154"); 

是你所需要的。

+0

它正在工作thax你 – Tum

相關問題