SMARTGWT 数据源 (GWT-RPC-DATASource) LISTGRID

2024-04-25

我在使用 smartGWT 绑定 ListGrid 中的数据源时遇到问题。我有 GWT-RPC-DataSource 并将其设置为我的数据源

grid.setDataSource(ds);

单击一键,我的数据源发生了一些更改,我正在生成新的数据源并与 smartgwt 的网格重新绑定。但它失败了。我努力了grid.重画()函数重绘网格。

下面是我的 GWTRPCDATASOURCE 类

public abstract class GwtRpcDataSource extends DataSource {

    /**
     * Creates new data source which communicates with server by GWT RPC. It is
     * normal server side SmartClient data source with data protocol set to
     * <code>DSProtocol.CLIENTCUSTOM</code> ("clientCustom" - natively supported
     * by SmartClient but should be added to smartGWT) and with data format
     * <code>DSDataFormat.CUSTOM</code>.
     */
    public GwtRpcDataSource() {
        setDataProtocol(DSProtocol.CLIENTCUSTOM);
        setDataFormat(DSDataFormat.CUSTOM);
        setClientOnly(false);
    }

    /**
     * Executes request to server.
     * 
     * @param request
     *            <code>DSRequest</code> being processed.
     * @return <code>Object</code> data from original request.
     */
    @Override
    protected Object transformRequest(DSRequest request) {
        String requestId = request.getRequestId();
        DSResponse response = new DSResponse();
        response.setAttribute("clientContext",
                request.getAttributeAsObject("clientContext"));
        // Asume success
        response.setStatus(0);
        switch (request.getOperationType()) {
        case FETCH:
            executeFetch(requestId, request, response);
            break;
        case ADD:
            executeAdd(requestId, request, response);
            break;
        case UPDATE:
            executeUpdate(requestId, request, response);
            break;
        case REMOVE:
            executeRemove(requestId, request, response);
            break;
        default:
            // Operation not implemented.
            break;
        }
        return request.getData();
    }

    /**
     * Executed on <code>FETCH</code> operation.
     * <code>processResponse (requestId, response)</code> should be called when
     * operation completes (either successful or failure).
     * 
     * @param requestId
     *            <code>String</code> extracted from
     *            <code>DSRequest.getRequestId ()</code>.
     * @param request
     *            <code>DSRequest</code> being processed.
     * @param response
     *            <code>DSResponse</code>. <code>setData (list)</code> should be
     *            called on successful execution of this method.
     *            <code>setStatus (&lt;0)</code> should be called on failure.
     */
    protected abstract void executeFetch(String requestId, DSRequest request,
            DSResponse response);

    /**
     * Executed on <code>ADD</code> operation.
     * <code>processResponse (requestId, response)</code> should be called when
     * operation completes (either successful or failure).
     * 
     * @param requestId
     *            <code>String</code> extracted from
     *            <code>DSRequest.getRequestId ()</code>.
     * @param request
     *            <code>DSRequest</code> being processed.
     *            <code>request.getData ()</code> contains record should be
     *            added.
     * @param response
     *            <code>DSResponse</code>. <code>setData (list)</code> should be
     *            called on successful execution of this method. Array should
     *            contain single element representing added row.
     *            <code>setStatus (&lt;0)</code> should be called on failure.
     */
    protected abstract void executeAdd(String requestId, DSRequest request,
            DSResponse response);

    /**
     * Executed on <code>UPDATE</code> operation.
     * <code>processResponse (requestId, response)</code> should be called when
     * operation completes (either successful or failure).
     * 
     * @param requestId
     *            <code>String</code> extracted from
     *            <code>DSRequest.getRequestId ()</code>.
     * @param request
     *            <code>DSRequest</code> being processed.
     *            <code>request.getData ()</code> contains record should be
     *            updated.
     * @param response
     *            <code>DSResponse</code>. <code>setData (list)</code> should be
     *            called on successful execution of this method. Array should
     *            contain single element representing updated row.
     *            <code>setStatus (&lt;0)</code> should be called on failure.
     */
    protected abstract void executeUpdate(String requestId, DSRequest request,
            DSResponse response);

    /**
     * Executed on <code>REMOVE</code> operation.
     * <code>processResponse (requestId, response)</code> should be called when
     * operation completes (either successful or failure).
     * 
     * @param requestId
     *            <code>String</code> extracted from
     *            <code>DSRequest.getRequestId ()</code>.
     * @param request
     *            <code>DSRequest</code> being processed.
     *            <code>request.getData ()</code> contains record should be
     *            removed.
     * @param response
     *            <code>DSResponse</code>. <code>setData (list)</code> should be
     *            called on successful execution of this method. Array should
     *            contain single element representing removed row.
     *            <code>setStatus (&lt;0)</code> should be called on failure.
     */
    protected abstract void executeRemove(String requestId, DSRequest request,
            DSResponse response);

    private ListGridRecord getEditedRecord(DSRequest request) {
        // Retrieving values before edit
        JavaScriptObject oldValues = request
                .getAttributeAsJavaScriptObject("oldValues");
        // Creating new record for combining old values with changes
        ListGridRecord newRecord = new ListGridRecord();
        // Copying properties from old record
        JSOHelper.apply(oldValues, newRecord.getJsObj());
        // Retrieving changed values
        JavaScriptObject data = request.getData();
        // Apply changes
        JSOHelper.apply(data, newRecord.getJsObj());
        return newRecord;
    }

}

我已将这个抽象类实现到我自己的名为 NTDatasource 的数据源类。

public class NTDataSource extends GwtRpcDataSource {

    public static int total = 991;
    Record[] records;
    public NTDataSource() {             
    }

    public void setData(List<NTListGridField> lstFields, Record[] records) {
//      setTestData(records);
        for (NTListGridField lstField : lstFields) {
            if (lstField.getType() == ListGridFieldType.DATE) {
                DataSourceDateField dateField = new DataSourceDateField(
                        lstField.getName());
                dateField.setHidden(lstField.getAttributeAsBoolean("visible"));
                if (lstField.getName().equals("id")) {
                    dateField.setHidden(true);
                }

                addField(dateField);

            } else {
                DataSourceTextField textField = new DataSourceTextField(
                        lstField.getName());
                textField.setHidden(lstField.getAttributeAsBoolean("visible"));
                if (lstField.getName().equals("id")) {
                    textField.setHidden(true);
                    textField.setPrimaryKey(true);
                }
                addField(textField);
            }
        }
        total = records.length;
        this.records = records;
    }

    @Override
    protected void executeFetch(String requestId, DSRequest request,
            DSResponse response) {
        // assume we have 1000 items.
        response.setTotalRows(total);
        int end = request.getEndRow();
        if (end > total) {
            end = total;
        }       
        Record returnRecords[] = new Record[end
                - request.getStartRow()];
        for (int i = request.getStartRow(); i < end; i++) {
            ListGridRecord r = new ListGridRecord();    
            r = (ListGridRecord) records[i];
            returnRecords[i - request.getStartRow()] = r;
        }
        GWT.log(" called from " + request.getStartRow() + " to "
                + request.getEndRow() + " result " + returnRecords.length, null);
        response.setData(returnRecords);
        processResponse(requestId, response);
    }

    @Override
    protected void executeAdd(String requestId, DSRequest request,
            DSResponse response) {
        // TODO Auto-generated method stub

    }

    @Override
    protected void executeUpdate(String requestId, DSRequest request,
            DSResponse response) {
        // TODO Auto-generated method stub

    }

    @Override
    protected void executeRemove(String requestId, DSRequest request,
            DSResponse response) {
        // TODO Auto-generated method stub

    }
}

这个问题我自己已经解决了。

答案是我需要使用 grid.fetchData() 方法并再次绑定数据源才能使用它....!我希望它可以帮助别人。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

SMARTGWT 数据源 (GWT-RPC-DATASource) LISTGRID 的相关文章

  • GWT 程序是否有办法判断它是处于托管模式还是 Web 模式?

    我希望我的 GWT 程序能够确定它是处于托管模式还是 Web 模式 有没有办法做到这一点 Thanks GWT isScript 在非托管模式下返回 true 在托管模式下返回 false http google web toolkit g
  • 如何在 GWT 2.7 应用程序中启用生产模式

    我想通过 gwt maven plugin 和 jenkins 在我的服务器上部署 GWT 2 7 应用程序 但是 在编译过程之后 当我启动我的应用程序时 我收到以下错误消息 Couldn t load APPLICATION NAME f
  • 如何从浏览器控制台访问 GWT 的 JsInterop 导出类型?

    我正在运行 GWT 应用程序 并且想使用 JsInterop 快速测试某些内容 具体来说 我导出了一个enum package com mypackage test JsType enum MyEnum A B C 我想在编写任何代码之前检
  • 如何使用 uibinder 创建带有子级的 gwt 复合组件?

    我想创建一个组件来装饰它的子组件 例如 mycomponent ui xml
  • 使用 SelectionModel 或 ListDataProvider 选择 CellList 中的元素

    我使用 CellList 列出数据 使用 ListDataProvider 管理数据 使用 SelectionModel 从 CellList 中选择元素并相应地生成事件 现在 当我使用 cellList getList set index
  • GWT Dev 模式和外部服务器出现间歇性序列化异常

    我有一个 GWT 应用程序 它在开发模式下与 GWT 的嵌入式码头服务器完美运行 但是 我需要转向使用外部码头服务器 出于各种原因 我遵循了 GWT 文档编译与调试 http www gwtproject org doc latest De
  • GWT 应用程序中使用的 Javascript 通用 clone() 方法

    我试图编写一个通用克隆函数 它应该能够进行真正的深度克隆 我遇到过这个链接 如何在 javascript 中深度克隆 https stackoverflow com questions 4459928 how to deep clone i
  • Spring security 已登录用户的重定向问题

    在使用我的基于 GWT 的 Web 应用程序实现 Spring Security 时 我找到 一切都按预期正常工作 除了以下事实 我打开了 login jsp 并给出了有效的用户登录凭据 提交后 成功重定向到主页 现在 当我在地址栏中编辑
  • 正则表达式和 GWT

    我的问题是 在GWT中使用正则表达式有没有好的解决方案 例如 我对 String split regex 的使用不满意 GWT 将代码翻译为 JS 然后将正则表达式用作 JS 正则表达式 但我无法使用 Java Matcher 或 Java
  • 在 Java 中如何将类作为参数传递?

    有什么方法可以将类作为 Java 中的参数传递并从该类中触发一些方法吗 void main callClass that class void callClass classObject classObject somefunction o
  • 带下拉箭头的 GWT 文本框

    我想在文本框中有一个下拉箭头 在我的例子中实际上是 SuggestBox GMail 执行此操作是为了实现高级搜索功能 打开高级搜索对话框 要使该箭头显示在 TextBox 的右侧并可单击 正确的 GWT 布局是什么 看看 GMail 我发
  • Servlet 过滤器在 AWS 上返回“代理错误”

    我已经设置了一个Filter为我的 GWT Web 应用程序添加爬网程序支持 这个想法是捕获所有包含 escaped fragment 并为爬虫提供快照 我已经设置了Filter使用 Guice 如下 filter through Craw
  • SMARTGWT 数据源 (GWT-RPC-DATASource) LISTGRID

    我在使用 smartGWT 绑定 ListGrid 中的数据源时遇到问题 我有 GWT RPC DataSource 并将其设置为我的数据源 grid setDataSource ds 单击一键 我的数据源发生了一些更改 我正在生成新的数据
  • 带有编辑器框架的 GWT 验证器

    有没有人意识到编辑器和 jsr 303 验证如何与 GWT 2 3 一起工作 未来 验证 API 已添加到 gwt sdk 但我无法使用编辑器框架验证实体 无论 我确实从来没有从客户端或服务器端抛出错误 这是一个代码片段 public cl
  • 如何向 CellList 添加或删除单个元素?

    如何添加 删除单个元素CellList http google web toolkit googlecode com svn javadoc 2 1 com google gwt user cellview client CellList
  • 如何使用 Ant 配置惰性或增量构建?

    Java编译器提供增量构建 所以javac蚂蚁任务也是如此 但大多数其他进程则不然 考虑到构建过程 它们将一组文件 源 转换为另一组文件 目标 我在这里可以区分两种情况 变压器cannot获取源文件的子集 仅获取整个集合 这里我们只能做懒惰
  • GWT 和身份验证

    保护 GWT Tomcat 应用程序执行身份验证和授权的最佳策略是什么 有两种基本策略 确保入口点安全 确保远程服务的安全 确保入口点安全 最简单的方法是使用常规 Web 应用程序安全工具限制对 GWT 生成的 html js 文件的访问
  • 如何使用 GWT 2.4 在服务器端动态创建 UI

    我正在尝试使用 Google Web Toolkit v2 4 创建用户界面 由于多种原因 我需要在运行时指定服务器上接口的内容 我的意思不仅仅是按钮需要动态标签等 而是整个 UI 需要在运行时创建 我的大部分 UI 都可以指定为直接的 H
  • TextField“更改”事件仅在模糊时触发

    通常 Change 事件将在 TextField 失去焦点 模糊 后触发 但我需要它在字段值发生变化时立即触发 而不需要失去对该字段的关注 KeyListener 不会删除它 因为该值可能来自条形码扫描仪等 有什么办法可以做到这一点吗 提前
  • 如何使用 GWT 检测操作系统?

    Basically what I want to know is to find out if my GWT application is running on a MacOS or any other operating system t

随机推荐

  • 苹果组合框架:如何并行执行多个发布者并等待所有发布者完成?

    我正在发现组合 我编写了以 组合 方式发出 HTTP 请求的方法 例如 func testRawDataTaskPublisher for url URL gt AnyPublisher
  • 使用不同的配置文件设置 Git 的开发和测试分支

    我们有一个 WordPress 安装 它有不同的实时 测试 开发配置文件 我知道如何让 Git 忽略wp config php文件 但我想在每个分支中有一个不同的 WP config 文件 这样当开发人员切换到 Dev 时 它将使用 Dev
  • 龙卷风 websocket 应用程序中的用户身份验证

    现在 我提高了我的龙卷风技能 并有一个关于用户身份验证的问题 我的解决方案是在首页上创建安全令牌 然后将其与其他数据一起发送 从 javascript 到龙卷风服务器 在其中检查和验证用户 我想到了 cookie 但我不知道如何读取 coo
  • Sql Server 数据库项目 - VS 2013 中缺少模板

    在 VS2012 中 我使用 Sql Server 数据库项目来管理我的数据库 我尝试将 Db 项目添加到新的 VS2013 解决方案中 但我似乎找不到模板 我在网上和已安装的模板中查看过 有任何想法吗 对我来说 它列在 其他语言 下 我有
  • 将等号('=')传递给 MediaWiki 模板中的参数

    如何在模板参数中使用 字符而不破坏模板解析器 我不是 MediaWIKI 开发人员 所以我没有调试代码或检查日志 我希望这里有人提供转义传递给模板的字符的提示 使用以下内容创建一个名为 Test 的模板 1 像这样 Test R 3 2 1
  • 使用curl解压gzip数据

    I added curl easy setopt client CURLOPT ENCODING gzip 到我的代码 我预计curl 会导致服务器发送压缩数据并解压缩它 实际上我在 HTTP 标头中看到数据被压缩 变化 Accept En
  • Codility 的复杂性达到顶峰

    我刚刚完成了以下 CodilityPeaks http codility com demo take sample test peaks问题 问题如下 给出一个由 N 个整数组成的非空零索引数组 A 峰值是大于其邻居的数组元素 更准确地说
  • 如何使用 JAX-WS 将 SOAP 标头添加到 SOAP 请求?

    我们需要使用其他团队开发的网络服务 使用JAX WS用于生成网络服务 我们正在使用wsimport生成客户端存根 问题是我需要将以下信息作为标头与 SOAP 主体一起传递
  • 如何更改 Github/Markdown 中图像的大小?

    我正在 Github 存储库中编辑 Readme md 文件 并插入了一张图片 请参阅https github com khpeek FMCW 雷达 https github com khpeek FMCW radar 图片占据了整个宽度
  • 有点好奇了解 .NET 中的表达式树

    我读过几篇文章和几篇stackoverflow com关于表达式树的帖子 我的大脑很难理解 问题 1 像DOM 文档对象模型 一样 它是逻辑的内存表示 2 有人解释说它是一种将可执行 代码转换为数据的机制 使用它我们可以生成表示代码的数据结
  • Theano 中的名称冲突

    我正在尝试在模块中导入 theano 但我得到了回溯 File media tarun 6A86CA8286CA4DEF develop pydy pydy codegen code py line 16 in
  • SearchManager - 添加自定义建议

    我已经阅读了有关构建搜索界面和添加自定义建议的所有在线文档 但我仍然不清楚这是如何工作的 文档说我必须 为您的建议构建一个表 例如在 SQLiteDatabase 中 并使用所需的列格式化表 我假设系统最终会自己用适当的建议填充此表 但是哪
  • gitk:悬停时显示分支名称

    你能告诉我如何让 gitk 工具在悬停时显示分支名称或建议能够这样做的工具吗 gitk 显示分支缠结 其中分支是无名的 我必须猜测哪个是 master 哪个是 stable 等 在 gitk 窗口的左下半部分 有一个信息行指定Branche
  • Docker 上的 MySQL?

    我是 Docker 新手 仍在探索中 我遇到了这个问题 可能看起来很愚蠢 但我真的被困住了 所以我有一个使用 MySQL 服务器的 Spring boot 应用程序 我想在容器上运行我的应用程序 我设法 运行一个没有 MySQL 的应用程序
  • 在 model.fit() 期间记录 Keras 中每个时期的计算时间

    我想比较不同模型之间的计算时间 在拟合期间 每个时期的计算时间被打印到控制台 Epoch 5 5 160000 160000 10s 我正在寻找一种方法来存储这些时间 其方式与模型指标类似 模型指标保存在每个时期并可通过历史对象获取 尝试以
  • 通过 DynamicMethod 调用 varargs 方法

    我正在尝试使用 DynamicMethod 调用非托管的类似 printf 的函数 在运行时我得到一个 BadImageFormatException 找不到索引 HRESULT 的异常 0x80131124 这是运行时的限制还是我发出的代
  • 如何使用 se.py 在 gem5 系统调用模拟模式下编译和运行可执行文件?

    有许多可能的错误和解决方法分散在不同的地方 任何人都可以提供至少一种详细的工作设置 以及确切的 gem5 和编译器版本 希望在 Ubuntu 上吗 最小的 Ubuntu 设置 首先要注意一件事 动态链接的可执行文件首先运行动态加载器 这意味
  • 如何仅为具有特定模板 ID 的列表添加事件接收器

    我正在为自定义列表模板添加 ItemAdding 事件接收器 事件接收器和列表模板都是由相同的功能部署的 同样的功能还可以创建列表实例 我遇到的问题是该事件是为每个列表项触发在其部署的地点 eventreceivre 的 Elements
  • 使用 C# 驱动程序从 MongoDB 集合上的文本查询中检索相关性有序结果

    我正在尝试对集合进行文本查询并按文本匹配顺序检索结果 The docs http docs mongodb org manual reference operator query text text search with addition
  • SMARTGWT 数据源 (GWT-RPC-DATASource) LISTGRID

    我在使用 smartGWT 绑定 ListGrid 中的数据源时遇到问题 我有 GWT RPC DataSource 并将其设置为我的数据源 grid setDataSource ds 单击一键 我的数据源发生了一些更改 我正在生成新的数据