Interface IUIImage2Listener


public interface IUIImage2Listener
Listener for changes in the UIImage2 property class, e.g. when a user uploads an image, orientation changes, zoom, crop points, etc.

An image the user picks is uploaded over HTTPS through the upload service of the client session, as soon as it passes the pixel check, and onImageSelection(UIImage2, String, ImageType, byte[], int, int, ImageOrientation, double, GRect, boolean) is called with its bytes once it has been received and verified. The upload events are default methods, so a listener overrides only what it needs; they are called on the application session's worker, as the upload service calls its listeners, and only while the component lives. A server that does not allow uploads ($upload.allow) receives the image over the WebSocket as before, and then no upload event is called.

Author:
Christopher Mindus
  • Method Details

    • onImageSelection

      void onImageSelection(UIImage2 image, String name, ImageType type, byte[] data, int width, int height, ImageOrientation orientation, double zoom, GRect rect, boolean isCircle)
      Invoked when the user has selected an image.
      Parameters:
      image - The image selection and upload property.
      name - The original file name on the client side.
      type - The image type.
      data - The original file data, uncropped.
      width - The original image in pixels.
      height - The original image height in pixels.
      orientation - The orientation.
      zoom - The zoom factor.
      rect - The cropping rectangle.
      isCircle - Flag indicating the image cropping is a circle if true, rectangle or square if false.
    • onImageModified

      void onImageModified(UIImage2 image, ImageOrientation orientation, double zoom, GRect rect)
      Invoked when the image has been modified.
      Parameters:
      image - The image selection and upload property.
      orientation - The orientation.
      zoom - The zoom.
      rect - The crop rectangle.
    • onImageChanged

      void onImageChanged(UIImage2 image, IImageTarget imageTarget)
      Change of image caused by the user selecting a new image (the imageTarget is null), some programmatic call not directly caused by the user, but as a result of a user change at some earlier point in time, or that the VirtualSpace value was changed.

      This method is not invoked when a user chooses a image, only e.g. programmatic changes when the UIImage2 property is updated with a URL from an image that has been stored, typically accessible from the web.

      Parameters:
      image - The image selection and upload property.
      imageTarget - The image target, null if a user has selected an image and the server application has not yet processed the image selected to save e.g. as a profile image.
    • onFileStarted

      default void onFileStarted(UIImage2 image, IUploadFile file)
      Invoked when the first chunk of the image file has been accepted by the server.
      Parameters:
      image - The image selection and upload property.
      file - The file being uploaded.
    • onFileProgress

      default void onFileProgress(UIImage2 image, IUploadFile file, long plainBytes, long plainTotal)
      Invoked as chunks of the image file arrive, at most once per second.
      Parameters:
      image - The image selection and upload property.
      file - The file being uploaded.
      plainBytes - The bytes received so far.
      plainTotal - The declared size of the file.
    • onFilePaused

      default void onFilePaused(UIImage2 image, IUploadFile file, String reason)
      Invoked once when the upload of the image file is paused, by the application or by the client (its page hidden, its network gone).
      Parameters:
      image - The image selection and upload property.
      file - The file being uploaded.
      reason - The reason whoever paused it gave, never null.
    • onFileResumed

      default void onFileResumed(UIImage2 image, IUploadFile file)
      Invoked once when a paused upload of the image file may continue.
      Parameters:
      image - The image selection and upload property.
      file - The file being uploaded.
    • onFileFailed

      default void onFileFailed(UIImage2 image, IUploadFile file, String reason)
      Invoked once when the upload of the image file failed its transfer or its verification, e.g. a file whose content is not the PNG or JPEG image it claims to be. The user is told by the client; onImageSelection(UIImage2, String, ImageType, byte[], int, int, ImageOrientation, double, GRect, boolean) is not invoked.
      Parameters:
      image - The image selection and upload property.
      file - The file.
      reason - The reason, e.g. typeMismatch, typeNotPermitted, sizeMismatch, corrupt.
    • onFileCancelled

      default void onFileCancelled(UIImage2 image, IUploadFile file, String reason)
      Invoked once when the upload of the image file was cancelled: by the user picking another image (user), by the value of the component being replaced from the server during the upload (replaced), by the disposal of the component (disposed), or by a timeout of the upload service (idle, start, maxPause); onImageSelection(UIImage2, String, ImageType, byte[], int, int, ImageOrientation, double, GRect, boolean) is not invoked.
      Parameters:
      image - The image selection and upload property.
      file - The file.
      reason - The reason.