当前位置: 代码迷 >> Web前端 >> Ext 表单交付 返回 action.result.msg
  详细解决方案

Ext 表单交付 返回 action.result.msg

热度:551   发布时间:2012-09-08 10:48:07.0
Ext 表单提交 返回 action.result.msg

???
??? ??? addForm = new Ext.FormPanel(
??? ??? ??? ??? {
??? ??? ??? ??? ??? url : 'accountBalance__operator',
??? ??? ??? ??? ??? defaultType : 'textfield',
??? ??? ??? ??? ??? labelAlign : 'right',
??? ??? ??? ??? ??? labelWidth : 120,
??? ??? ??? ??? ??? autoHeight : true,
??? ??? ??? ??? ??? bodyStyle : 'padding:5px',
??? ??? ??? ??? ??? border : false,
??? ??? ??? ??? ??? // fileUpload : true,
??? ??? ??? ??? ??? baseCls : 'x-plain',
??? ??? ??? ??? ??? items :
??? ??? ??? ??? ??? ??? [merchant,wagerType,businessmoney,orderno,game,period,infoArea
??? ??? ??? ??? ??? ??? ??? ],
??? ??? ??? ??? ??? buttonAlign : 'center',
??? ??? ??? ??? ??? minButtonWidth : 60,
??? ??? ??? ??? ??? buttons : [ {
??? ??? ??? ??? ??? ??? text : '提交',
??? ??? ??? ??? ??? ??? handler : function(btn) {
??? ??? ??? ??? ??? ??? ??? if (addForm.getForm().isValid() == false) {
??? ??? ??? ??? ??? ??? ??? ??? Ext.Msg.show({
??? ??? ??? ??? ??? ??? ??? ??? ??? title : '提示',
??? ??? ??? ??? ??? ??? ??? ??? ??? msg : '无法提交,请检查输入项!',
??? ??? ??? ??? ??? ??? ??? ??? ??? buttons : Ext.MessageBox.OK,
??? ??? ??? ??? ??? ??? ??? ??? ??? icon : Ext.Msg.INFO
??? ??? ??? ??? ??? ??? ??? ??? });
??? ??? ??? ??? ??? ??? ??? ??? return;
??? ??? ??? ??? ??? ??? ??? }
??? ??? ??? ??? ??? ??? ??? if (addForm.getForm().isValid()) {
??? ??? ??? ??? ??? ??? ??? ??? btn.disable();
??? ??? ??? ??? ??? ??? ??? ??? addForm.getForm().submit({
??? ??? ??? ??? ??? ??? ??? ??? ??? waitTitle : '请稍候',
??? ??? ??? ??? ??? ??? ??? ??? ??? waitMsg : '正在提交表单数据,请稍候...',

??? ??? ??? ??? ??? ??? ??? ??? ??? success : function(form, action) {
??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ? Ext.Msg.show({ title : '提示', msg :
??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ? '成功!!', buttons :
??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ? Ext.MessageBox.OK, icon :
??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ? Ext.Msg.INFO });
??? ??? ??? ??? ??? ??? ??? ??? ??? ??? addWindow.close();
??? ??? ??? ??? ??? ??? ??? ??? ??? },
??? ??? ??? ??? ??? ??? ??? ??? ??? failure : function(form, action) {
??? ??? ??? ??? ??? ??? ??? ??? ??? ??? Ext.Msg.alert('错误', action.result.msg);
??? ??? ??? ??? ??? ??? ??? ??? ??? }
??? ??? ??? ??? ??? ??? ??? ??? });
??? ??? ??? ??? ??? ??? ??? ??? btn.enable();
??? ??? ??? ??? ??? ??? ??? }
??? ??? ??? ??? ??? ??? }
??? ??? ??? ??? ??? }, {
??? ??? ??? ??? ??? ??? text : '重置',
??? ??? ??? ??? ??? ??? handler : function() {
??? ??? ??? ??? ??? ??? ??? addForm.getForm().reset();
??? ??? ??? ??? ??? ??? }
??? ??? ??? ??? ??? }, {
??? ??? ??? ??? ??? ??? text : '取消',
??? ??? ??? ??? ??? ??? handler : function() {
??? ??? ??? ??? ??? ??? ??? addWindow.close();
??? ??? ??? ??? ??? ??? }
??? ??? ??? ??? ??? } ]
??? ??? ??? ??? })

?

action类

?

拼json字符串

??? jsonMsg = "{\"success\":false,\"msg\":\""+entity.getErrorMsg()+"\"}";

?

?

?????? FundManageReturn entity = (FundManageReturn) frontClient.syncSend(fm);
??? ??? ??? if(entity!=null){
??? ??? ??? ??? if(!entity.isStatus()){
??? ??? ??? ??? ??? jsonMsg = "{\"success\":false,\"msg\":\""+entity.getErrorMsg()+"\"}";
??? ??? ??? ??? ??? this.getResponse().setCharacterEncoding("UTF-8");
??? ??? ??? ??? ??? this.getResponse().getWriter().write(jsonMsg);
??? ??? ??? ??? ??? this.getResponse().getWriter().flush();
??? ??? ??? ??? }else{
??? ??? ??? ??? ??? jsonMsg = "{\"success\":true,\"msg\":\"成功\"}";
??? ??? ??? ??? ??? this.getResponse().setCharacterEncoding("UTF-8");
??? ??? ??? ??? ??? this.getResponse().getWriter().write(jsonMsg);
??? ??? ??? ??? ??? this.getResponse().getWriter().flush();
??? ??? ??? ??? }

  相关解决方案