[jboss-user] [JBoss Seam] - Re: New fileUpload component

msystems do-not-reply at jboss.com
Fri Jan 26 05:51:42 EST 2007


I'm using JSF 1.1 RI and the file upload component doesn't work.

It will work just fine if I include the following lines of code in the FileUpload.decode():


  |       if (request instanceof HttpServletRequestWrapper) { // Needed for JSF 1.1 RI
  |           request = ((HttpServletRequestWrapper) request).getRequest();
  |       }
  | 

FileUpload.decode():

   
  |    @Override
  |    public void decode(FacesContext context)
  |    {
  |       super.decode(context);
  |       
  |       Object request = context.getExternalContext().getRequest();
  | 
  |       if (request instanceof HttpServletRequestWrapper) { // Needed for JSF 1.1 RI
  |           request = ((HttpServletRequestWrapper) request).getRequest();
  |       }
  |       
  |       if (request instanceof MultipartRequest)
  |       {
  |          MultipartRequest req = (MultipartRequest) request;
  |          
  |          String clientId = getClientId(context);
  |          byte[] fileData = req.getFileBytes(clientId);
  |          String contentType = req.getFileContentType(clientId);
  |          String fileName = req.getFileName(clientId);
  |          
  |          getValueBinding("data").setValue(context, fileData);
  |          
  |          ValueBinding vb = getValueBinding("contentType");
  |          if (vb != null)
  |             vb.setValue(context, contentType);
  |          
  |          vb = getValueBinding("fileName");
  |          if (vb != null)
  |             vb.setValue(context, fileName);
  |       }      
  |    }
  | 

Regards

Kenneth


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4006741#4006741

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4006741



More information about the jboss-user mailing list