Class FileFieldChangeBehavior

All Implemented Interfaces:
Serializable, IComponentAwareEventSink, IRequestListener, IComponentAwareHeaderContributor, IClusterable
Direct Known Subclasses:
FileFieldSizeCheckBehavior

public abstract class FileFieldChangeBehavior extends AjaxEventBehavior

A Behavior that can be used on FileUploadField-s to receive ajax callback with detailed information about the chosen files when an event occurs (default: "onchange"). When the ajax call is triggered (for example user selects files for upload) the metadata about the file(s) (name, size, type, last modify date) is sent with the ajax call to the server (so the content is not). Subclasses of this class can respond to this event by implementing the onEvent(AjaxRequestTarget, FileList) method.

Works with single or multiple enabled file inputs.

Note that this behaviour only works with browsers implementing the Html5 FileApi (Chrome 11, Firefox 4). It does not change or break browsers not implementing the api.

Author:
akiraly
See Also:
  • Field Details

    • JAVASCRIPT_REF

      protected static final ResourceReference JAVASCRIPT_REF
    • DEFAULT_MAX_NUM_OF_FILES

      public static final int DEFAULT_MAX_NUM_OF_FILES
      Default maximum number of files that are processed from the ajax request: 100.
      See Also:
  • Constructor Details

    • FileFieldChangeBehavior

      public FileFieldChangeBehavior()
      Default constructor: the monitored event is "onchange" and maxNumOfFiles is DEFAULT_MAX_NUM_OF_FILES.
    • FileFieldChangeBehavior

      public FileFieldChangeBehavior(int maxNumOfFiles)
      Constructor. The monitored event is "onchange".
      Parameters:
      maxNumOfFiles - maximum number of files that are processed from the ajax request, non-negative
    • FileFieldChangeBehavior

      protected FileFieldChangeBehavior(String event, int maxNumOfFiles)
      Constructor.
      Parameters:
      event - event for which the ajax call is triggered, not-null
      maxNumOfFiles - maximum number of files that are processed from the ajax request, non-negative
  • Method Details