2012-06-11 5 views
1

안녕하세요 저는 GWT를 사용하여 서블릿을 사용하여 파일을 보냅니다.ListBox 및 파일을 함께 보낼 수 없습니다.

처음에는 파일을 서버로 보내려고합니다. 그것은 잘 작동했다.

이제 ormPanel에서 3 개의 목록 상자를 추가했습니다.

private ListBox propertyNamelist = getListBox("propertyName"); 
    private ListBox propertyTypeList = getListBox("propertyType"); 
    private ListBox propertyValueList = getListBox("propertyValue"); 

private ListBox getListBox(String name){ 

      listbox = new ListBox(); 
      listbox.setName(name); 

     return listbox; 
    } 

이어서 FormPanel에 첨가한다.

formPanel.setWidget(propertyNamelist); 
formPanel.setWidget(propertyTypeList); 
formPanel.setWidget(propertyValueList); 
formPanel.submit(); 

서버 측.

try { 

     ServletFileUpload upload = new ServletFileUpload(); 

     FileItemIterator iterator = upload.getItemIterator(request); 
     while (iterator.hasNext()) { 
      FileItemStream item = iterator.next(); 
      stream = item.openStream(); 

      if (item.isFormField()) { 
       log.warning("Got a form field: " + item.getFieldName()); 
       System.out.println(" chk fg " +item.getFieldName() +" = "+ Streams.asString(item.openStream())); 


      } else { 

       log.warning("Got an uploaded file: " + item.getFieldName() 
         + ", name = " + item.getName()); 
       fileName = item.getName(); 
       mimetype = item.getContentType(); 

      } 
     } 

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

출력 :

WARNING: Got a form field: propertyValue 
Jun 11, 2012 11:37:55 AM com.google.apphosting.utils.jetty.JettyLogger warn 
WARNING: /UploadFileServlet: org.apache.commons.fileupload.FileItemStream$ItemSkippedException 
chk fg propertyValue = motivation 

날에 따른 동기리스트 박스에 더 값이 그대로 PropertyValue리스트 박스의 제 1 값이다.

그리고 더 많은 목록 상자가 표시되어야합니다.

나는 이런 일이 벌어지고있는 것을 이해할 수 없다.

참고 : RPC를 통해 목록 상자를 보낼 수 없습니다.이 목록 상자는 서버 및 서버에 외부 저장소로 보낼 파일과 관련이 있습니다.

일부 plz 도움말.

답변

2

FormPanel 위젯의 내용은 해당 이름이 FormPanel 인 것을 의미하는 setWidget입니다.

// put all widgets together in some container (you can have a more complex layout) 
FlowPanel container = new FlowPanel(); 
container.add(fileUpload); 
container.add(propertyNameList); 
container.add(propertyTypeList); 
container.add(propertyValueList); 

// set the container as the content of the form, so named form widgets will get 
// their value sent to the server. 
formPanel.setWidget(container); 
+0

내 모든 실수 .. 난 그냥 실현 that..thanks :

당신은 당신의 FormPanel 내부에 여러 위젯을 넣어, 그래서 당신의 위젯을 넣어 (예 : FlowPanel로) 중간 컨테이너를 사용하려면 @ThomasBroyer – GameBuilder

+0

이 나를 도울 수 있습니다 [link] [http://stackoverflow.com/q/10980022/780393] – GameBuilder

관련 문제