Examples of UploadedFile


Examples of org.apache.myfaces.trinidad.model.UploadedFile

   * @param name the name under which the file is stored.  In HTML forms,
   *   this will be derived from the "name" set on the <input> tag.
   */
  public UploadedFile getUploadedFile(String name)
  {
    UploadedFile file = _map.get(name);
    if (file == null)
      return null;

    return new FixFilename(file, _characterEncoding);
  }
View Full Code Here

Examples of org.apache.myfaces.trinidad.model.UploadedFile

  public void dispose()
  {
    Iterator<UploadedFile> iterator = _map.values().iterator();
    while (iterator.hasNext())
    {
      UploadedFile file = iterator.next();
      file.dispose();
    }

    _map.clear();

    _totalMemory    = 0;
View Full Code Here

Examples of org.apache.myfaces.trinidad.model.UploadedFile

      final RequestContext   context,
      final ExternalContext  externalContext,
      final UploadedFiles     files,
      final MultipartFormItem item) throws IOException
  {
    final UploadedFile temp = new TempUploadedFile(item);

    final UploadedFile file =
      context.getUploadedFileProcessor().processFile(externalContext.getRequest(), temp);

    if (file != null)
    {
      // Store the file.
      files.__put(item.getName(), file);

      if (_LOG.isFine())
      {
        _LOG.fine("Uploaded file " + file.getFilename() + "(" +
            file.getLength() + " bytes) for ID " + item.getName());
      }
    }
  }
View Full Code Here

Examples of org.apache.myfaces.trinidad.model.UploadedFile

    _panelPage = panelPage;
  }

  public void fileUploaded(ValueChangeEvent event) throws IOException
  {
    UploadedFile file = (UploadedFile) event.getNewValue();
    if (file != null)
    {
      FacesContext context = FacesContext.getCurrentInstance();
      FacesMessage message = new FacesMessage(
         "Uploaded file " + file.getFilename() +
         " (" + file.getLength() + " bytes)"+". Bytes available to read: " +
         file.getInputStream().available());
      context.addMessage(event.getComponent().getClientId(context), message);
    }
  }
View Full Code Here

Examples of org.apache.myfaces.trinidad.model.UploadedFile

      final RequestContext   context,
      final ExternalContext  externalContext,
      final UploadedFiles     files,
      final MultipartFormItem item) throws IOException
  {
    final UploadedFile temp = new TempUploadedFile(item);
    Map<String, Object> sessionMap = externalContext.getSessionMap();
    Map<String, Object> requestMap = externalContext.getRequestMap();
   
    _copyParamsFromSessionToRequestMap(sessionMap, requestMap,
      UploadedFileProcessor.MAX_MEMORY_PARAM_NAME,
      UploadedFileProcessor.MAX_DISK_SPACE_PARAM_NAME,
      UploadedFileProcessor.TEMP_DIR_PARAM_NAME);
   
    final UploadedFile file =
      context.getUploadedFileProcessor().processFile(externalContext.getRequest(), temp);

    if (file != null)
    {
      // Store the file.
      files.__put(item.getName(), file);

      if (_LOG.isFine())
      {
        _LOG.fine("Uploaded file " + file.getFilename() + "(" +
            file.getLength() + " bytes) for ID " + item.getName());
      }
    }
  }
View Full Code Here

Examples of org.apache.myfaces.trinidad.model.UploadedFile

      final RequestContext   context,
      final ExternalContext  externalContext,
      final UploadedFiles     files,
      final MultipartFormItem item) throws IOException
  {
    final UploadedFile temp = new TempUploadedFile(item);

    final UploadedFile file =
      context.getUploadedFileProcessor().processFile(externalContext.getRequest(), temp);

    if (file != null)
    {
      // Store the file.
      files.__put(item.getName(), file);

      if (_LOG.isFine())
      {
        _LOG.fine("Uploaded file " + file.getFilename() + "(" +
            file.getLength() + " bytes) for ID " + item.getName());
      }
    }
  }
View Full Code Here

Examples of org.apache.myfaces.trinidad.model.UploadedFile

    // Since we override getSubmittedValue() entirely,
    // detect auto submit manually
    detectAutoSubmit(context, component, clientId);

    Object result = null;
    UploadedFile file = null;

    UploadedFiles files = UploadedFiles.getUploadedFiles(context);
    if (files != null)
    {
      file = files.getUploadedFile(clientId);
    }

    // If we couldn't find a file (or the file is empty), return "FALSE" to indicate that
    // the file upload *was* available, but didn't upload a file
    // this time.
    if (file == null || file.getLength() == 0)
      result = Boolean.FALSE;
    else
      result = file;

    return result;
View Full Code Here

Examples of org.apache.myfaces.trinidad.model.UploadedFile

  {
    // Convert FALSE back into null
    if (submittedValue == Boolean.FALSE)
      return null;

    UploadedFile file = (UploadedFile) submittedValue;
    if(file.getLength() == -1)
    {
      FacesMessage fm = MessageFactory.getMessage(context, "org.apache.myfaces.trinidad.UPLOAD");
      throw new ConverterException(fm);
    }

    FacesBean bean = getFacesBean(component);
    Converter converter = getConverter(bean);
    // support converter for the <inputFile> component
    if(converter != null)
    {
      // create a unique key (component class name + filename) and use this
      // key to add the actual uploaded file to the requestMap
      String fileNameKey = component.getClass().getName() + "." + file.getFilename();
      context.getExternalContext().getRequestMap().put(fileNameKey, file);
     
      // applying the above convention. The String here is just the
      // unique key which the converter has to use to look for the
      // actual uploaded file.
View Full Code Here

Examples of org.apache.myfaces.trinidad.model.UploadedFile

    // Since we override getSubmittedValue() entirely,
    // detect auto submit manually
    detectAutoSubmit(context, component, clientId);

    Object result = null;
    UploadedFile file = null;

    UploadedFiles files = UploadedFiles.getUploadedFiles(context);
    if (files != null)
    {
      file = files.getUploadedFile(clientId);
    }

    // If we couldn't find a file (e.g. does not exist OR the file is empty),
    // return "FALSE" to indicate that...
    // the file upload *was* available, but didn't upload a file
    // this time.
    if (file == null || file.getLength() == 0)
      result = Boolean.FALSE;
    else
      result = file;

    return result;
View Full Code Here

Examples of org.apache.myfaces.trinidad.model.UploadedFile

  {
    // Convert FALSE back into null
    if (submittedValue == Boolean.FALSE)
      return null;

    UploadedFile file = (UploadedFile) submittedValue;
    if(file.getLength() == -1)
    {
      // There was a failure while one of the UploadedFileProcessor in the chain processed this file,
      // we expect the details to be in opaqueData
      String errorMessage = file.getOpaqueData().toString();
      FacesMessage fm = MessageFactory.getMessage(context,
                                                  FacesMessage.SEVERITY_WARN,
                                                  "org.apache.myfaces.trinidad.UPLOAD_FAILURE",
                                                  new Object[]{errorMessage}, component);
      throw new ConverterException(fm);
    }

    FacesBean bean = getFacesBean(component);
    Converter converter = getConverter(component, bean);
    // support converter for the <inputFile> component
    if(converter != null)
    {
      // create a unique key (component class name + filename) and use this
      // key to add the actual uploaded file to the requestMap
      String fileNameKey = component.getClass().getName() + "." + file.getFilename();
      context.getExternalContext().getRequestMap().put(fileNameKey, file);

      // applying the above convention. The String here is just the
      // unique key which the converter has to use to look for the
      // actual uploaded file.
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.