1

ExtJS を利用した UI の JSON を学習し始めていますが、サーブレットから JSP コンボボックスにデータを渡す方法に問題があります。

私のサーブレットの出力はすでに問題ありません。(そう願っています。:))これは私のサーブレットコードです..

JSONArray jsonarray = new JSONArray();
            ResultSetMetaData rsmd = rs.getMetaData();

            int y = 1;
            while(rs.next()){
                int numColumns = rsmd.getColumnCount();
                JSONObject obj = new JSONObject();

            for (int i=1; i<numColumns+1; i++) {
                String column_name = rsmd.getColumnName(1);
                    String column_value = rs.getString(i);
                    obj.put(column_value, y);

                }

                jsonarray.put(obj);

                 y++;
            }   

次に、ExtJS のコンボボックスは次のとおりです。

            xtype: 'combo',
    name: 'genre',
    fieldLabel: 'Genre',
    mode: 'local',
    store: genres2,
    width: 120,             
    forceSelection: true,
    typeAhead: true,
    triggerAction: 'all',
    emptyText:'Select materials...',
    selectOnFocus:true,
    displayField: 'column_value'

var genres2 = new Ext.data.SimpleStore({
    root: 'rows',
    totalProperty: 'totalCount',
    method: 'POST',
    proxy: new Ext.data.HttpProxy({  
        url : '/ExtJS_Sample/ConnectionServlet'
    }), 

    autoLoad: true
});

genres2.load();

私はそれを正しくやっていると思います。:) 助けてください。

4

1 に答える 1

0

Ext.data.SimpleStore定義には、「フィールド」プロパティが定義されている必要があります

例えば。、

Ext.data.SimpleStore({
root: 'rows',
fields: [ {name: 'company'},
          {name: 'price', type: 'float'},
          {name: 'change', type: 'float'},
          {name: 'pctChange', type: 'float'}],
totalProperty: 'totalCount',
method: 'POST',
proxy: new Ext.data.HttpProxy({  
          url : '/ExtJS_Sample/ConnectionServlet'
       }), 
autoLoad: true 
});
于 2013-03-15T07:52:19.697 に答える