getting started with smart gwt
I am developing a small scale app using smart gwt 2.4. I chose smart gwt over other html specific RIAs as it has rich ui and to avoid cross browser issues. I have 2 pages in my app. Initially, the details that the user enters in page 1 is used to fetch data that has to be displayed in page 2 and from then on, any change that has to be made can be made in page 2 itself. the user needn't navigate back to page 1 to get a new set of data. 1) Now, how do i navigate between pages. i have defined these pages as two separate modules. I wil need to pass data from page 1 to page 2. Is there an efficient way to do this? 2) In one of my pages i have defined two autocomplete combo boxes. data for one of the combo boxes will be fetched on load and the data for the second one depends on the value of the 1st combo box. I tried adding change and changed event listeners for the 1st combo box but both of the events are getting fired for every letter type. I need to fetch data once the user selects the value.
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);
}
}
});
}
here i have a combo box category whose values will fetched on load. when the user selects a category by typing it in the combo box the control helps by displaying matched values in the drop down. for every key press, the event is getting is fired. i have added a syso to print the typed values. I need to fetch the sub category only when the user is done selecting the category.
Any pointers will be really useful. thanks
For your second question: According to your need I think you can implement module as per this link. OR if you want to implement it yourself by handling changed event, to stop firing change event on every key press you can use this:
comboBoxItem.setChangeOnKeypress(false);
精彩评论