智能 GWT 入门
我正在使用 smart gwt 2.4 开发一个小型应用程序。我选择 smart gwt 而不是其他 html 特定的 RIA,因为它具有丰富的 ui 并可以避免跨浏览器问题。 我的应用程序中有 2 个页面。最初,用户在页面 1 中输入的详细信息用于获取必须在页面 2 中显示的数据,从那时起,任何必须进行的更改都可以在页面 2 本身中进行。用户无需导航回第 1 页即可获取一组新数据。 1)现在,我如何在页面之间导航。我已将这些页面定义为两个单独的模块。我需要将数据从第 1 页传递到第 2 页。有没有有效的方法来做到这一点? 2)在我的其中一个页面中,我定义了两个自动完成组合框。其中一个组合框的数据将在加载时获取,第二个组合框的数据取决于第一个组合框的值。我尝试为第一个组合框添加更改和更改事件侦听器,但这两个事件都会针对每种字母类型而被触发。一旦用户选择了值,我就需要获取数据。
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 来打印键入的值。仅当用户完成选择类别时,我才需要获取子类别。
任何指针都会非常有用。 谢谢
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于你的第二个问题:根据你的需要,我认为你可以按照这个链接。
或者,如果您想通过处理更改事件来自己实现它,以停止在每次按键时触发更改事件,您可以使用以下命令:
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: