자바스크립트/Ext JS
[ExtJS] Proxy
베니94
2011. 5. 21. 16:08
store: Ext.create('Ext.data.TreeStore', { model: 'ForumBrowser.Forum', root: { expanded: true }, proxy: { actionMethods: { // Post방식으로 변경.. create: 'POST', destroy: 'DELETE', read: 'POST', update: 'POST' }, type: 'ajax', // 'jsonp' : cross domain지원된다. 단 get방식만 지원한다. 2000byte지원 url: '/smpl/forum/forums-remote.jsp', reader: { type: 'json', root: 'children' }, success: function ( result, request) { // 여기서 이부분은 실행되지 않는다. var textArea = Ext.get('log').dom; textArea.value += result.responseText + "\n"; Ext.MessageBox.alert('Success', 'Data return from the server: '+ result.responseText); //doJSON(result.responseText); }, //실패 시에 수행될 콜백 함수 failure: function ( result, request) { // 여기서 이부분은 실행되지 않는다. Ext.MessageBox.alert('Failed', 'Successfully posted form: '+result.date); } , listeners: { // 서버쪽 호출의 실패를 리스너를 통해 확인. // 서버쪽 프로그램 호출시실패할 경우. exception: function(proxy, type, action, options, response, arg){ //alert('서버호출 에러 :'+ proxy.url); Ext.MessageBox.alert('Failed', '서버호출 에러 :'+ proxy.url); // your error handling code console.error(" Exception: \nProxy: %1.o \nType: %s \nAction: %s \nOptions: %1.o \nResponse: %1.o \nArguments: %1.o ",proxy, type, action, options, response, arg); } //single: true, //scope: this } }, setExtraParam: function (name, value){ // 파라메터세팅시 사용 this.proxy.extraParams = this.proxy.extraParams || {}; this.proxy.extraParams[name] = value; this.proxy.applyEncoding(this.proxy.extraParams); } })