• extjs经典form的submit()和ajax()


    extjs 的submit:

    // 发送请求
                    this.formPanel.getForm().submit({
                                url : this.saveUrl,
                                method:'post',
                                params:{
                                    billId:recordId
                                },
                                success : function(form,action) {
                                    Ext.MessageBox.alert('提示',action.result.msg,function(){
                                       this.store.reload();
                                       this.hide();
                                    },this);
                                },
                                failure : function(form, action) {
                                    Ext.MessageBox.alert('提示', '请求失败!');
                                    newTab.close();
                                    waitMask.hide();
                                },
                                scope:this
                            });

    extjs的extreturn实体类如下:

    package cn.edu.hbcf.common.vo;
     
    /**
     * Ext Ajax 返回对象
     *
     * @author LiPenghui
     * @date 2012-02-21 19:30:00
     *
     */

    public class ExtReturn {

        private boolean success; // 是否成功
        private Object msg; // 返回消息
        private Object otherObject;// 其他对象

        public ExtReturn() {

        }

        /**
         * 是否更新成功的构造方法
         *
         * @param success
         *            是否成功
         * @param msg
         *            消息
         */
        public ExtReturn(boolean success, Object msg) {
            this.success = success;
            this.msg = msg;
            this.otherObject = "";
        }

        /**
         * 是否更新成功的构造方法
         *
         * @param success
         *            是否成功
         * @param msg
         *            消息
         * @param otherObject
         *            其他对象
         */
        public ExtReturn(boolean success, Object msg, Object otherObject) {
            this.success = success;
            this.msg = msg;
            this.otherObject = otherObject;
        }

        /**
         * 异常时的构造函数
         *
         * @param errormsg
         *            异常消息
         */
        public ExtReturn(Object errormsg) {
            this.success = false;
            this.msg = false;
            this.otherObject = "";
        }

        /**
         * 判断是否成功
         *
         * @return
         */
        public boolean isSuccess() {
            return success;
        }

        /**
         * 设置返回是否成功的状态
         *
         * @param success
         */
        public void setSuccess(boolean success) {
            this.success = success;
        }

        /**
         * 设置其他对象
         *
         * @return
         */
        public Object getOtherObject() {
            return otherObject;
        }

        /**
         * 获取其他对象
         *
         * @param otherObject
         */
        public void setOtherObject(Object otherObject) {
            this.otherObject = otherObject;
        }

        /**
         * 获取返回的消息
         *
         * @return
         */
        public Object getMsg() {
            return msg;
        }

        /**
         * 设置返回的消息
         *
         * @param msg
         */
        public void setMsg(Object msg) {
            this.msg = msg;
        }
    }

    Controller如下:

        /**
         * 描述:新增无项目材料采购信息都数据库中
         * @param materials 要新增的无项目材料采购信息
         * @return
         */
        @RequestMapping(value="/insert",method=RequestMethod.POST)
        @ResponseBody
        public ExtReturn insert(ProjectMaterials materials){
            materials.setId(UUID.randomUUID().toString().replace("-", ""));
            int result = service.insert(materials);
            if(result>0){
                return new ExtReturn(true, "新增成功!");
            }
            return new ExtReturn(false, "新增失败!");
        }

    extjs的ajax如下:其实跟submit是一样的

    Ext.Ajax.request({
                                            url : this.url.deleteUrl,
                                            method : 'post',
                                            params : {
                                                id : rec.get('id')
                                            },
                                            success : function(response, options) {
                                                var text = Ext
                                                        .decode(response.responseText);
                                                Ext.Msg.alert('提示', text.msg);
                                                if (text.success) {
                                                    this.store.reload();
                                                }
                                            },
                                            failure : function(response, options) {
                                                Ext.MessageBox.alert('提示', '请求失败!');
                                            },
                                            scope : this
                                        });

  • 相关阅读:
    企业如何实现数字化跃进
    看阿里Alibaba/IOCgolang有感
    WunderGraph 组件
    dremio 增量反射处理
    几个不错的数据加速工具
    citus 11 参考简单使用
    citus 11 的一些参考资料
    kuwala 开源构建分析工作流开发的无代码数据平台
    cube.js 配置json schema
    amass OWASP开源的深入的攻击面映射和资产发现工具
  • 原文地址:https://www.cnblogs.com/zrui-xyu/p/4917239.html
Copyright © 2020-2023  润新知