一般form里都会有复选框,我在提交form表单时,对于checkboxgroup的取值问题困扰了好一会儿了,特来这里请假一下。
1.第一种方式:
           xtype: 'checkboxgroup',
           columns: 3,
           name:'hobbies', 
          items: [
                {boxLabel: '足球', name: 'hobbie', inputValue: 1},
                {boxLabel: '篮球', name: 'hobbie', inputValue: 2},
                {boxLabel: '排球', name: 'hobbie', inputValue: 3},
                {boxLabel: '游泳', name: 'hobbie', inputValue: 4},
                {boxLabel: 'DOTA', name: 'hobbie', inputValue: 5}
                ]后台通过迭代得到的是: hobbie--->[reference:c0-e5,reference:c0-e6,reference:c0-e7],  hobbies为null2.第二种方式:
            xtype: 'checkboxgroup',
            columns: 3,
            name:'hobbies', 
            items: [
                {boxLabel: '足球', name: 'football', inputValue:'1'},
                {boxLabel: '篮球', name: 'basketball', inputValue: '2'},
                {boxLabel: '游泳', name: 'swim', inputValue: '3'},
                {boxLabel: 'DOTA', name: 'dota', inputValue: '4'},
                {boxLabel: '乒乓球', name: 'ping-pong', inputValue: '5'}
这样提交到后台,得到的值是
basketball--->2
football--->1
dota--->4
hobbies还是为null。这样肯定不是我们想要的结果啊。。求指点~

解决方案 »

  1.   

    对了,是使用dwr的方式提交的form. dwrFormInfo.getFormInfo(myForm.getForm().getValues()); 
    后台接受一个封装过来的map,迭代得到表单的各项信息的。
    public void getFormInfo(Map formMap){ 
     Set<Map.Entry<String, Object>> set = formMap.entrySet();
     
            for (Iterator<Map.Entry<String, Object>> it = set.iterator(); it.hasNext();) {
                Map.Entry<String, Object> entry = (Map.Entry<String, Object>) it.next();
                System.out.println(entry.getKey() + "--->" + entry.getValue());
            }      
    System.out.println("hobbies "+formMap.get("hobbies"));