public void decodeSimple(FacesContext context, FileUpload fileUpload, FileItem file) {
   if (file.getName().equals("")) {
     fileUpload.setSubmittedValue("");
   } else {
     fileUpload.setSubmittedValue(new DefaultUploadedFile(file));
   }
 }
  @Override
  public void decode(FacesContext context, UIComponent component) {
    FileUpload fileUpload = (FileUpload) component;
    String clientId = fileUpload.getClientId(context);
    MultipartRequest multipartRequest = getMultiPartRequestInChain(context);

    if (multipartRequest != null) {
      FileItem file = multipartRequest.getFileItem(clientId);

      if (fileUpload.getMode().equals("simple")) {
        decodeSimple(context, fileUpload, file);
      }
    }
  }
  /**
   * Return null if no file is submitted in simple mode
   *
   * @param context
   * @param component
   * @param submittedValue
   * @return
   * @throws ConverterException
   */
  @Override
  public Object getConvertedValue(
      FacesContext context, UIComponent component, Object submittedValue)
      throws ConverterException {
    FileUpload fileUpload = (FileUpload) component;

    if (fileUpload.getMode().equals("simple")
        && submittedValue != null
        && submittedValue.equals("")) {
      return null;
    } else {
      return submittedValue;
    }
  }
  protected void encodeMarkup(FacesContext context, FileUpload fileUpload) throws IOException {
    if (fileUpload.getMode().equals("simple")) {
      ResponseWriter writer = context.getResponseWriter();
      String clientId = fileUpload.getClientId(context);

      writer.startElement("input", null);
      writer.writeAttribute("type", "file", null);
      writer.writeAttribute("id", clientId, null);
      writer.writeAttribute("name", clientId, null);

      if (fileUpload.getStyle() != null) {
        writer.writeAttribute("style", fileUpload.getStyle(), "style");
      }
      if (fileUpload.getStyleClass() != null) {
        writer.writeAttribute("class", fileUpload.getStyleClass(), "styleClass");
      }
      if (fileUpload.isDisabled()) {
        writer.writeAttribute("disabled", "disabled", "disabled");
      }

      writer.endElement("input");
    }
  }