我正在開發使用智能gwt 2.4的小型應用程序。我選擇了智能gwt而不是其他html特定的RIA,因爲它具有豐富的UI並避免了跨瀏覽器問題。 我在我的應用程序中有2頁。最初,用戶在頁面1中輸入的詳細信息用於獲取必須在頁面2中顯示的數據,並且從那時起,必須在頁面2中進行任何必須進行的更改。用戶不需要回到頁面1來獲得一組新的數據。 1)現在,我如何瀏覽頁面。我已經將這些頁面定義爲兩個單獨的模塊。我將需要將數據從第1頁傳遞到第2頁。有沒有一種有效的方法可以做到這一點? 2)在我的一個頁面中,我定義了兩個自動完成組合框。其中一個組合框的數據將在加載時獲取,第二個數據的數據取決於第一個組合框的值。我嘗試添加更改並更改第一個組合框的事件偵聽器,但是每個字母都會觸發兩個事件。一旦用戶選擇了值,我需要獲取數據。智能gwt入門
public void onModuleLoad()
{
final ComboBoxItem category = new ComboBoxItem("categoryName", "Category");
category.setTitle("Select");
category.setChangeOnKeypress(false) ;
category.setType("comboBox");
category.setWidth(250);
category.setIcons(icon);
category.setChangeOnKeypress(false);
final ComboBoxItem subCategory = new ComboBoxItem("subCategoryName", "Sub Category");
subCategory.setTitle("Select");
subCategory.setType("comboBox");
subCategory.setWidth(250);
subCategory.addClickHandler(new com.smartgwt.client.widgets.form.fields.events.ClickHandler()
{
@Override
public void onClick(com.smartgwt.client.widgets.form.fields.events.ClickEvent event)
{
// call to servlet[url] to get the sub categories for the selected category.
RequestBuilder requestBuilder = new RequestBuilder(RequestBuilder.GET, "url"+ selectedCategoryName);
try {
requestBuilder.sendRequest(null, new RequestCallback() {
@Override
public void onResponseReceived(Request request, Response response)
{
String xmlText = response.getText();
// Code to handle the received response.
}
@Override
public void onError(Request request, Throwable exception)
{
exception.printStackTrace();
}});
} catch (RequestException e) {
e.printStackTrace();
}
catch (Exception e) {
e.printStackTrace();
}
}
});
category.addChangeHandler(new ChangeHandler()
{
@Override
public void onChange(ChangeEvent event)
{
if(null!=event.getValue() && event.getValue()!="")
{
selectedCategoryName = event.getValue().toString();
System.out.println(selectedCategoryName);
}
}
});
}
這裏我有一個組合框的類別,其值將在負載上獲取。當用戶通過在組合框中鍵入它來選擇一個類別時,控件通過在下拉菜單中顯示匹配值來提供幫助。對於每一次按鍵,事件正在被解僱。我已經添加了一個syso來打印輸入的值。只有當用戶完成選擇類別時,我才需要獲取子類別。
任何指針都會非常有用。 謝謝
我已經實現了我的組合框按本[鏈接](HTTP:// www.smartclient.com/smartgwt/showcase/#styled_combobox_category)。我的問題是每次按鍵都會引發更改事件。假設我正在搜索CAT。它被C,A和T各發射3次。我需要一個事件來通知聽衆我選擇了CAT。一旦我具有CAT的價值,我將發起另一個請求來獲取基於CAT [第一個值]的數據。截至目前,其情況並非如此。 – 2011-05-06 04:38:17
您是否實現了comboBoxItem.setChangeOnKeypress(false);? – RAS 2011-05-06 06:14:04
yes.i嘗試過。在我的第一個問題上的任何指針。 – 2011-05-09 09:10:24