Class FileUploadField

    • Constructor Detail

      • FileUploadField

        public FileUploadField​(java.lang.String id)
        See Also:
        Component(String)
      • FileUploadField

        public FileUploadField​(java.lang.String id,
                               IModel<? extends java.util.List<FileUpload>> model)
        Parameters:
        id - See Component
        model - the model holding the uploaded FileUploads
    • Method Detail

      • getFileUpload

        public FileUpload getFileUpload()
        Returns:
        the first uploaded file if HTML5 <input type="file" multiple /> is used and the browser supports multiple, otherwise returns the single uploaded file.
        See Also:
        getFileUploads()
      • getFileUploads

        public java.util.List<FileUpload> getFileUploads()
        Returns:
        a list of all uploaded files. The list is empty if no files were selected. It will return more than one files if:
        • HTML5 <input type="file" multiple /> is used
        • the browser supports multiple attribute
        • the user has selected more than one files from the Select file dialog
      • updateModel

        public void updateModel()
        Description copied from class: FormComponent
        Updates this components model from the request, it expects that the object is already converted through the convertInput() call that is called by the validate() method when a form is being processed. By default it just does this:
         setModelObject(getConvertedInput());
         
        DO NOT CALL THIS METHOD DIRECTLY UNLESS YOU ARE SURE WHAT YOU ARE DOING. USUALLY UPDATING YOUR MODEL IS HANDLED BY THE FORM, NOT DIRECTLY BY YOU.
        Specified by:
        updateModel in interface IFormModelUpdateListener
        Overrides:
        updateModel in class FormComponent<java.util.List<FileUpload>>
      • getInputAsArray

        public java.lang.String[] getInputAsArray()
        Description copied from class: FormComponent
        Gets the request parameters for this component as strings.
        Overrides:
        getInputAsArray in class FormComponent<java.util.List<FileUpload>>
        Returns:
        The values in the request for this component
      • convertValue

        protected java.util.List<FileUpload> convertValue​(java.lang.String[] value)
                                                   throws org.apache.wicket.util.convert.ConversionException
        Description copied from class: FormComponent
        Subclasses should overwrite this if the conversion is not done through the type field and the IConverter. WARNING: this method may be removed in future versions. If conversion fails then a ConversionException should be thrown
        Overrides:
        convertValue in class FormComponent<java.util.List<FileUpload>>
        Parameters:
        value - The value can be the getInput() or through a cookie
        Returns:
        The converted value. default returns just the given value
        Throws:
        org.apache.wicket.util.convert.ConversionException - If input can't be converted
      • isMultiPart

        public boolean isMultiPart()
        Overrides:
        isMultiPart in class FormComponent<java.util.List<FileUpload>>
        Returns:
        True if this component encodes data in a multipart form submit
      • onDetach

        protected void onDetach()
        Clean up at the end of the request. This means closing all inputstreams which might have been opened from the fileUpload.
        Overrides:
        onDetach in class FormComponent<java.util.List<FileUpload>>
        See Also:
        Component.onDetach()
      • forceCloseStreamsOnDetach

        protected boolean forceCloseStreamsOnDetach()
        The FileUploadField will close any input streams you have opened in its FileUpload by default. If you wish to manage the stream yourself (e.g. you want to use it in another thread) then you can override this method to prevent this behavior.
        Returns:
        true if stream should be closed at the end of request