org.richfaces.component

## Class AbstractFileUpload

- java.lang.Object
- - javax.faces.component.UIComponent
  - - javax.faces.component.UIComponentBase
    - - org.richfaces.component.AbstractFileUpload

- All Implemented Interfaces:
    EventListener, javax.faces.component.PartialStateHolder, javax.faces.component.StateHolder, javax.faces.component.TransientStateHolder, javax.faces.event.ComponentSystemEventListener, javax.faces.event.FacesListener, javax.faces.event.SystemEventListenerHolder, AjaxActivatorProps, AjaxProps, CoreProps, DisabledProps, ErrorProps, EventsKeyProps, EventsMouseProps, I18nProps
  Direct Known Subclasses:
    UIFileUpload

      public abstract class AbstractFileUpload
      extends javax.faces.component.UIComponentBase
      implements AjaxProps, CoreProps, DisabledProps, EventsKeyProps, EventsMouseProps, ErrorProps, I18nProps

  The <rich:fileUpload> component allows the user to upload files to a server. It features multiple uploads, progress bars, restrictions on file types, and restrictions on sizes of the files to be uploaded.

  Author:
    Konstantin Mishin, Lukas Fryc, Simone Cinti

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `COMPONENT_FAMILY`
    `static String` | `COMPONENT_TYPE`

    - ### Fields inherited from class javax.faces.component.UIComponent

      `ATTRS_WITH_DECLARED_DEFAULT_VALUES, BEANINFO_KEY, bindings, COMPOSITE_COMPONENT_TYPE_KEY, COMPOSITE_FACET_NAME, CURRENT_COMPONENT, CURRENT_COMPOSITE_COMPONENT, FACETS_KEY, HONOR_CURRENT_COMPONENT_ATTRIBUTES_PARAM_NAME, VIEW_LOCATION_KEY`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbstractFileUpload()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `acceptsFile(UploadedFile file)` Checks whether this component can accept given `UploadedFile`..
    `void` | `addFileUploadListener(FileUploadListener listener)` Add a new `FileUploadListener` to the set of listeners interested in being notified when `FileUploadEvent`s occur.
    `abstract String` | `getAcceptedTypes()` Defines comma separated list of file extensions accepted by component.
    `List<String>` | `getAcceptedTypesList()` Get a list of accepted types from `getAcceptedTypes()` attribute.
    `abstract String` | `getAddLabel()` The label for the Add button.
    `abstract String` | `getClearAllLabel()` The label for the Clear button.
    `abstract String` | `getClearLabel()` The label displayed for the Clear link
    `abstract String` | `getDeleteLabel()` The label displayed for the Delete link
    `abstract String` | `getDoneLabel()` The label displayed when a file is successfully uploaded.
    `abstract javax.el.MethodExpression` | `getFileUploadListener()` A listener function on the server side after each file is uploaded.
    `FileUploadListener[]` | `getFileUploadListeners()` Return the set of registered `FileUploadListener`s for this `AbstractFileUpload` instance.
    `abstract String` | `getListHeight()` Defines height of file list.
    `abstract long` | `getMaxFileSize()` Defines the maximum allowed size of a file.
    `abstract Integer` | `getMaxFilesQuantity()` Defines maximum number of files allowed to be uploaded.
    `abstract String` | `getOnclear()` Javascript code executed when a file is cleared
    `abstract String` | `getOnerror()` The client-side script method to be called when an error has occurred during Ajax communications
    `abstract String` | `getOnfileselect()` Javascript code executed when a file is selected
    `abstract String` | `getOnfilesubmit()` Javascript code executed when a file is submitted
    `abstract String` | `getOnsizerejected()` Javascript code executed when a file exceeds the allowed size defined by maxFileSize parameter.
    `abstract String` | `getOntyperejected()` Javascript code executed when a file does not meet the conditions stated by acceptedTypes parameter.
    `abstract String` | `getOnuploadcomplete()` Javascript code executed when a file upload is complete
    `abstract String` | `getServerErrorLabel()` The label displayed when a file upload fails due to a server error.
    `abstract String` | `getSizeExceededLabel()` The label displayed when a file exceeds the size limit.
    `abstract String` | `getUploadLabel()` The label for the Upload button.
    `abstract boolean` | `isImmediateUpload()` If "true" upload stats immediately after file selection
    `abstract boolean` | `isNoDuplicate()` If "true" duplicate file uploads are prevented
    `void` | `processEvent(javax.faces.event.ComponentSystemEvent event)`
    `void` | `queueEvent(javax.faces.event.FacesEvent event)` Increments number of `FileUploadEvent` which were queued
    `void` | `removeFileUploadListener(FileUploadListener listener)` Remove an existing `FileUploadListener` (if any) from the set of listeners interested in being notified when `FileUploadListener`s occur.

    - ### Methods inherited from class javax.faces.component.UIComponentBase

      `addClientBehavior, addFacesListener, broadcast, clearInitialState, decode, encodeAll, encodeBegin, encodeChildren, encodeEnd, findComponent, getAttributes, getChildCount, getChildren, getClientBehaviors, getClientId, getDefaultEventName, getEventNames, getFacesContext, getFacesListeners, getFacet, getFacetCount, getFacets, getFacetsAndChildren, getId, getParent, getPassThroughAttributes, getRenderer, getRendererType, getRendersChildren, getValueBinding, invokeOnComponent, isRendered, isTransient, markInitialState, processDecodes, processRestoreState, processSaveState, processUpdates, processValidators, removeFacesListener, restoreAttachedState, restoreState, saveAttachedState, saveState, setId, setParent, setRendered, setRendererType, setTransient, setValueBinding, visitTree`

    - ### Methods inherited from class javax.faces.component.UIComponent

      `getClientId, getCompositeComponentParent, getContainerClientId, getCurrentComponent, getCurrentCompositeComponent, getFamily, getListenersForEventClass, getNamingContainer, getPassThroughAttributes, getResourceBundleMap, getStateHelper, getStateHelper, getTransientStateHelper, getTransientStateHelper, getValueExpression, initialStateMarked, isCompositeComponent, isInView, isVisitable, popComponentFromEL, pushComponentToEL, restoreTransientState, saveTransientState, setInView, setValueExpression, subscribeToEvent, unsubscribeFromEvent`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface org.richfaces.component.attribute.AjaxProps

      `getExecute, getOnbegin, getStatus`

    - ### Methods inherited from interface org.richfaces.component.attribute.AjaxActivatorProps

      `getData, getOnbeforedomupdate, getOncomplete, getRender, isLimitRender, isResetValues`

    - ### Methods inherited from interface org.richfaces.component.attribute.CoreProps

      `getStyle, getStyleClass, getTitle`

    - ### Methods inherited from interface org.richfaces.component.attribute.DisabledProps

      `isDisabled`

    - ### Methods inherited from interface org.richfaces.component.attribute.EventsKeyProps

      `getOnkeydown, getOnkeypress, getOnkeyup`

    - ### Methods inherited from interface org.richfaces.component.attribute.EventsMouseProps

      `getOnclick, getOndblclick, getOnmousedown, getOnmousemove, getOnmouseout, getOnmouseover, getOnmouseup`

    - ### Methods inherited from interface org.richfaces.component.attribute.I18nProps

      `getDir, getLang`

- - ### Field Detail

    - #### COMPONENT_TYPE

          public static final String COMPONENT_TYPE

      See Also:
        Constant Field Values

    - #### COMPONENT_FAMILY

          public static final String COMPONENT_FAMILY

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### AbstractFileUpload

          public AbstractFileUpload()

  - ### Method Detail

    - #### getAcceptedTypes

          public abstract String getAcceptedTypes()

      Defines comma separated list of file extensions accepted by component. The format of the file extension can be "png" or ".png", the second format will filter extensions in the dialog window. The component does not provide any feedback when rejecting file. For introducing feedback for rejection, use ontyperejected parameter.

    - #### getMaxFilesQuantity

          public abstract Integer getMaxFilesQuantity()

      Defines maximum number of files allowed to be uploaded. After a number of files in the list equals to the value of this attribute, "Add" button disappears and nothing could be uploaded even if you clear the whole list. In order to upload files again you should rerender the component. (Negative numbers means no limits; default value -1).

    - #### getMaxFileSize

          public abstract long getMaxFileSize()

      Defines the maximum allowed size of a file. Files exceeding the size will not be added in the component. Default value is 0 (no limit).

    - #### isNoDuplicate

          public abstract boolean isNoDuplicate()

      If "true" duplicate file uploads are prevented

      Default is "false"

    - #### isImmediateUpload

          public abstract boolean isImmediateUpload()

      If "true" upload stats immediately after file selection

      Default is "false"

    - #### getOnfileselect

          public abstract String getOnfileselect()

      Javascript code executed when a file is selected

    - #### getOnfilesubmit

          public abstract String getOnfilesubmit()

      Javascript code executed when a file is submitted

    - #### getOntyperejected

          public abstract String getOntyperejected()

      Javascript code executed when a file does not meet the conditions stated by acceptedTypes parameter.

    - #### getOnsizerejected

          public abstract String getOnsizerejected()

      Javascript code executed when a file exceeds the allowed size defined by maxFileSize parameter.

    - #### getOnuploadcomplete

          public abstract String getOnuploadcomplete()

      Javascript code executed when a file upload is complete

    - #### getOnclear

          public abstract String getOnclear()

      Javascript code executed when a file is cleared

    - #### getOnerror

          public abstract String getOnerror()

      The client-side script method to be called when an error has occurred during Ajax communications
      Specified by:
        `getOnerror` in interface `ErrorProps`

    - #### getAddLabel

          public abstract String getAddLabel()

      The label for the Add button.

    - #### getUploadLabel

          public abstract String getUploadLabel()

      The label for the Upload button.

    - #### getClearAllLabel

          public abstract String getClearAllLabel()

      The label for the Clear button.

    - #### getDoneLabel

          public abstract String getDoneLabel()

      The label displayed when a file is successfully uploaded.

    - #### getSizeExceededLabel

          public abstract String getSizeExceededLabel()

      The label displayed when a file exceeds the size limit.

    - #### getServerErrorLabel

          public abstract String getServerErrorLabel()

      The label displayed when a file upload fails due to a server error.

    - #### getClearLabel

          public abstract String getClearLabel()

      The label displayed for the Clear link

    - #### getDeleteLabel

          public abstract String getDeleteLabel()

      The label displayed for the Delete link

    - #### getListHeight

          public abstract String getListHeight()

      Defines height of file list.

      Default value is "210px".

    - #### processEvent

          public void processEvent(javax.faces.event.ComponentSystemEvent event)
                            throws javax.faces.event.AbortProcessingException

      Specified by:
        `processEvent` in interface `javax.faces.event.ComponentSystemEventListener`
      Overrides:
        `processEvent` in class `javax.faces.component.UIComponent`
      Throws:
        `javax.faces.event.AbortProcessingException`

    - #### getFileUploadListener

          public abstract javax.el.MethodExpression getFileUploadListener()

      A listener function on the server side after each file is uploaded. The listener should process files as required, such as storing them in the session/db/filesystem/ directory. The component itself does not store uploaded files, so if the listener is not implemented they are not stored anywhere

    - #### addFileUploadListener

          public void addFileUploadListener(FileUploadListener listener)

      Add a new `FileUploadListener` to the set of listeners interested in being notified when `FileUploadEvent`s occur.

      Parameters:
        `listener` - The `FileUploadListener` to be added
      Throws:
        `NullPointerException` - if `listener` is `null`

    - #### getFileUploadListeners

          public FileUploadListener[] getFileUploadListeners()

      Return the set of registered `FileUploadListener`s for this `AbstractFileUpload` instance. If there are no registered listeners, a zero-length array is returned.

    - #### removeFileUploadListener

          public void removeFileUploadListener(FileUploadListener listener)

      Remove an existing `FileUploadListener` (if any) from the set of listeners interested in being notified when `FileUploadListener`s occur.

      Parameters:
        `listener` - The `FileUploadListener` to be removed
      Throws:
        `NullPointerException` - if `listener` is `null`

    - #### getAcceptedTypesList

          public List<String> getAcceptedTypesList()

      Get a list of accepted types from `getAcceptedTypes()` attribute.

    - #### acceptsFile

          public boolean acceptsFile(UploadedFile file)

      Checks whether this component can accept given `UploadedFile`.. First, the number of enqueued `FileUploadEvent` events can't exceed `getMaxFilesQuantity()`. Then, the file extension of uploaded file needs to be acceptable by this component (see `getAcceptedTypes()`).

    - #### queueEvent

          public void queueEvent(javax.faces.event.FacesEvent event)

      Increments number of `FileUploadEvent` which were queued
      Overrides:
        `queueEvent` in class `javax.faces.component.UIComponentBase`

Copyright © 2015 JBoss by Red Hat. All Rights Reserved.