通过lotus脚本代理返回JSON字符串

时间:2014-09-17 07:12:10

标签: json extjs lotusscript

我正在尝试通过lotusscript代理构建一个JSON字符串。我从ExtJS onReady()函数调用此代理。

它总是让我得到html标签,如果我给这样的标题,

Print |content-type: application/json|      
Print StrLeftBack(jSonStr,",")

它不返回字符串但只发送空白对象。如果我直接在浏览器上发布它,它会以json格式打印正确的字符串。只有在从ExtJS调用它时,它才能很好地返回。

感谢任何人对我在这里失踪的意见。

提前致谢。


这是我的JS代码,我在Chrome上的网络选项卡下看不到任何内容,并且在控制台下也没有错误消息。

  Ext.Loader.setConfig({
  enabled : true,
  disableCaching : false
});

Ext.require([
                'Ext.data.*', 
                'Ext.grid.*',
                'Ext.ux.grid.FiltersFeature'
         ]);

Ext.define('Person', {
    extend: 'Ext.data.Model',
    fields: ['name', 'role', 'status', 'goal', 'planned', 'subject', 'plannedestimate', 'actualduration', 'priority', 'ticketid', 'type', 'startdate', 'enddate', 'comments']
});

Ext.onReady(function(){

    var store = Ext.create('Ext.data.Store', {
        autoLoad: true,
        autoDestroy: true,
        autoSync: false,
        sorters: {
            property : 'name',
            direction: 'ASC'
        },
        model: 'Person',
        proxy: {
            type: 'ajax',
            url: '/database.nsf/(POC-($agt_createJSONData_Project))?openagent',
            reader: {
                type: 'json',
                root: 'items'
            },
            writer: {
                type: 'json'
            },
            noCache: false
        },
        listeners: {
                'load' :  function(store,operation,options) {

            var temp = Ext.getCmp('myPanel')
            var temp1 = temp.store.proxy.reader.jsonData
            console.log(temp1)
            console.log(JSON.stringify(temp1))
            }
        }
    });

    var local = true;

     var filters = {
        ftype: 'filters',
        // encode and local configuration options defined previously for easier reuse
        //encode: encode, // json encode the filter query
        local: local   // defaults to false (remote filtering)

    };

     gridDock = [{
        id: 'activeStorePaging',
         xtype: 'toolbar',
         dock: 'bottom',
         items: [
           {
               text: 'Clear Filter Data',
               handler: function () {
                   grid.filters.clearFilters();
               } 
           },
           "-",
           {
               text: 'Clear localStorage',
               handler: function () {
                localStorage.gridData=""
               } 
           }            
        ]
     }]

    var grid = Ext.create('Ext.grid.Panel', {
        renderTo: 'gridHere',
        id: 'myPanel',
        frame: true,
        features: [filters],
        height: 400,
        title: 'Users',
        store: store,
        iconCls: 'icon-user',
        // paging bar on the bottom
        bbar: gridDock,
        columns: [{
            header: 'Name',
            sortable: true,
            dataIndex: 'name',
            filterable: true
        }, {
            text: 'Role',
            sortable: true,
            dataIndex: 'role',
            field: {
                xtype: 'textfield'
            },
            filterable: true
        }, {
            text: 'Status',
            sortable: true,
            dataIndex: 'status',
            field: {
                xtype: 'textfield'
            },
            filterable: true
        }, {
            text: 'Goal',
            sortable: true,
            dataIndex: 'goal',
            field: {
                xtype: 'textfield'
            },
            filterable: true
        },{
            text: 'Planned',
            width: 80,
            sortable: true,
            dataIndex: 'planned',
            field: {
                xtype: 'textfield'
            },
            filterable: true
        },{
            text: 'Subject',
            width: 80,
            sortable: true,
            dataIndex: 'subject',
            field: {
                xtype: 'textfield'
            },
            filterable: true
        },{
            text: 'Planned Estimate',
            width: 80,
            sortable: true,
            dataIndex: 'plannedestimate',
            field: {
                xtype: 'textfield'
            },
            filterable: true
        },{
            text: 'Actual Duration',
            width: 80,
            sortable: true,
            dataIndex: 'actualduration',
            field: {
                xtype: 'textfield'
            },
            filterable: true
        },{
            text: 'Priority',
            width: 80,
            sortable: true,
            dataIndex: 'priority',
            field: {
                xtype: 'textfield'
            },
            filterable: true
        },{
            text: 'Ticket ID',
            width: 80,
            sortable: true,
            dataIndex: 'ticketid',
            field: {
                xtype: 'textfield'
            },
            filterable: true
        },{
            text: 'Type',
            width: 80,
            sortable: true,
            dataIndex: 'type',
            field: {
                xtype: 'textfield'
            },
            filterable: true
        },{
            text: 'Start Date',
            width: 80,
            sortable: true,
            dataIndex: 'startdate',
            field: {
                xtype: 'textfield'
            },
            filterable: true
        },{
            text: 'End Date',
            width: 80,
            sortable: true,
            dataIndex: 'enddate',
            field: {
                xtype: 'textfield'
            },
            filterable: true
        },{
            text: 'Comments',
            width: 80,
            sortable: true,
            dataIndex: 'comments',
            field: {
                xtype: 'textfield'
            },
            filterable: true
        }]
    });
    }); 

浏览器对openagent的回应:

[{"name":"Alexander Prishchepov","role":"Dev Reviewer","status":"Not yet started","goal":"Dev Completion only","planned":"Y","subject":"Installer - BEFORE_BACKUP_RUN_PROCESS stage out of place","plannedestimate":"0","actualduration":"0","priority":"","ticketid":"APRV-9NEJUX","type":"Bug","startdate":"","enddate":"","comments":""}]

0 个答案:

没有答案