从gwt中的Formpanel接收数据 [英] receive data from Formpanel in gwt

查看:84
本文介绍了从gwt中的Formpanel接收数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用FormPanel. oN FormPanel

I am trying to use FormPanel. oN FormPanel

  formPanel.setWidget(flexTable);

添加了一个复选框,一个listBox和FileUpload

A check box , a listBox and FileUpload is added

flexTable.setWidget(4, 1,listBox);
flexTable.setWidget(5, 1, fileUpload);
flexTable.setWidget(6, 1, checkBox);
 // More Code

编写Servlet代码以获取仅对于fileUpload正常运行的所有值. 如何获取listBox的checkBox的值.

A Servlet code is written to get the all the values which running fine only for fileUpload. How to get the value of checkBox an ListBox.

protected void doPost(HttpServletRequest request, 
        HttpServletResponse response) 
                        throws ServletException, IOException { 

    byte[] buffer = new byte[1310720];// 10 MB

     try {

        ServletFileUpload upload = new ServletFileUpload();

        FileItemIterator iterator = upload.getItemIterator(request);

         while (iterator.hasNext()) {
             FileItemStream item = iterator.next();
             InputStream stream = item.openStream();

             if (item.isFormField()) {
                  // WHAT TO DO??

                } else {

                  int len;

                  while ((len = stream.read(buffer, 0, buffer.length)) != -1) {
                    response.getOutputStream().write(buffer, 0, len);                       
                  }
                }
         }

    } catch (FileUploadException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

}

Plz帮助获取checkBox和List Box的值.

Plz help to get the value of checkBox and List Box.

推荐答案

查看此问题的答案:

See the answer to this question: Passing parameters along with a multipart/form-data upload form (Java Http Post Upload) on how to get the values on the server side.

要将值发送到服务器,您需要通过ListBox和CheckBox小部件上的setName()方法在每个小部件上设置一个名称.名称是item.getFieldName()返回的名称.

To send the values to the server you need to set a name on each widget via the setName() method on the ListBox and CheckBox widgets. The name is what item.getFieldName() returns.

这篇关于从gwt中的Formpanel接收数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆