Error: ReferenceError, response is not defined

在用Ext+pring+hibernate+dwr时遇Error: ReferenceError, response is not defined错误
发现有两个原因:
1.没有把后台传来的对象进行
2.
var ds = new Ext.data.Store({
proxy: new Ext.data.DWRProxy(swsMstrService.findpaged, true),
reader: new Ext.data.ListRangeReader({
totalProperty: 'totalSize',
id: 'id'
}, recordType),
remoteSort: false
});
后台没有给这里的id传入正确的值
public class PkSwsMstr {
private int id;
private SwsMstr swsMstr;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}

public PkSwsMstr(int id, SwsMstr swsMstr) {
super();
this.id = id;
this.swsMstr = swsMstr;
}
public SwsMstr getSwsMstr() {
return swsMstr;
}
public void setSwsMstr(SwsMstr swsMstr) {
this.swsMstr = swsMstr;
}


}


完整例子
function initGrid(){
var recordType = Ext.data.Record.create([
{name: "id", type: "int"},
{name: "swsNbr",mapping:"swsMstr.swsNbr", type: "string"},
{name: "custcode", mapping:"swsMstr.custcode", type: "string"},
{name: "stampusername", mapping:"swsMstr.stampusername", type: "string"},
{name: "stockcode", mapping:"swsMstr.stockcode", type: "string"},
{name: "swsRefNo", mapping:"swsMstr.swsRefNo", type: "string"},
{name: "swsSinNbr", mapping:"swsMstr.swsSinNbr", type: "string"},
{name: "swsRmks", mapping:"swsMstr.swsRmks", type: "string"},
{name: "swsStatus", mapping:"swsMstr.swsStatus", type: "string"}
]);

// create the Data Store
var ds = new Ext.data.Store({
proxy: new Ext.data.DWRProxy(swsMstrService.findpaged, true),
reader: new Ext.data.ListRangeReader({
totalProperty: 'totalSize',
id: 'id'
}, recordType),
remoteSort: false
});

var cm = new Ext.grid.ColumnModel(
[
{
header: '入倉單號',
width: 100,
sortable: true,
dataIndex: 'swsNbr'
},
{
header: '客戶代碼',
width: 60,
sortable: true,
dataIndex: 'custcode'
},
]
);
var grid = new Ext.grid.Grid('mygrid', {
ds: ds,
cm: cm,
selModel: new Ext.grid.RowSelectionModel({singleSelect:true}),
enableColLock:false,
autoExpandColumn:'colOperate',
loadMask: false
});

obj=grid;
// make the grid resizable, do before render for better performance
var rz = new Ext.Resizable('mygrid', {
wrap:true,
minHeight:100,
pinned:true,
handles: 's'
});
rz.on('resize', grid.autoSize, grid);

// render it
grid.render();

//包括了前一页,后一页,第一页,最后一页,刷新,以及提示信息
var gridFoot = grid.getView().getFooterPanel(true);

// add a paging toolbar to the grid's footer
var paging = new Ext.PagingToolbar(gridFoot, ds, {
pageSize: 10,
displayInfo: true,
displayMsg: 'display {0} - {1} of {2}',
emptyMsg: "no record"
});

ds.load({params:{start:0,limit:10}});

)


Ext.onReady(init);


还有类ListRange
public class ListRange implements Serializable
{
private Object[] data;
private int totalSize;

public Object[] getData() { return data; }
public void setData(Object[] data) { this.data = data; }
public int getTotalSize() { return totalSize; }
public void setTotalSize(int totalSize) { this.totalSize = totalSize;}
}


最后service中的方法
public ListRange findpaged(Map condition) {
int start = Integer.parseInt(condition.get("start").toString());
int limit = Integer.parseInt(condition.get("limit").toString());
int pageNo = start/limit+1;

Page page = swsMstrDAO.findPage(pageNo, limit);
ListRange listRange= new ListRange();
List list = (List)page.getResult();
Collection alist=new ArrayList();
//System.out.println("list's length==="+list.size());
for(int i=0;i {
SwsMstr sm = (SwsMstr)list.get(i);
//System.out.println("sm.getCustcode==="+sm.getCustcode());
alist.add(new PkSwsMstr(i,sm));
}
//System.out.println("alist's length==="+alist.size());
listRange.setData(alist.toArray());
listRange.setTotalSize((int)page.getTotalCount());
//listRange.setTotalSize((int)page.getTotalCount());
return listRange;
}

你可能感兴趣的:(Ext)