Class InputUpload

All Implemented Interfaces:
Serializable, overit.geocall.marks.MethodExposer, overit.geocall.marks.NameExposer, Arrangeable, Badgeable, ValueValidator, Identified, Tool, overit.geocall.ux.configurability.UIConfigurable, overit.geocall.ux.edm.ModelConfigurable

@Component public class InputUpload extends Input implements Arrangeable
This class implements the graphic user interface element that allows you to select a resource from the filesystem that will be sent to the server when the Form is submitted.
It is important to insert this component into a form with the method parameter set to FILE (Form.setMETHOD(java.lang.String)); furthermore, submitting the form cannot be done through an ajax event but must be executed as a page event.
On the server side, to retrieve the forwarded file, simply extract it from the web parameters using the WebParameters.getFile(java.lang.String) method, indicating the name of the resource.
See Also:
GCApi:
component
  • Field Details

    • _accept

      protected String _accept
    • _multiple

      protected boolean _multiple
  • Constructor Details

    • InputUpload

      public InputUpload()
  • Method Details

    • setACCEPT

      public void setACCEPT(String mediaType)
      Restrict the type of the selectable files.
      Parameters:
      mediaType - it's possible to restrict the accepted file using the following rules:
      • file_extension: A file extension starting with the dot character, e.g: .gif, .jpg, .png, .doc
      • audio/*: All sound files are accepted
      • video/*: All video files are accepted
      • image/*: All image files are accepted
      • media_type: A valid media type, with no parameters. Look at IANA Media Types for a complete list of standard media types
      To specify more than one value, separate the values with a comma (e.g. "audio/*,video/*,image/*")
    • setMULTIPLE

      public void setMULTIPLE(String multiple)
      Indicates if the user is allowed to select more than one file.
      Parameters:
      multiple - A string that represents a boolean value ("true" or "1", "false" or "0").
      If the string is not recognized as a boolean value, it will be used the default value, that is false
    • prepareName

      protected String prepareName()
      Overrides:
      prepareName in class Input
    • setup

      protected void setup()
      Description copied from class: Component
      Setup the Component
      Overrides:
      setup in class Input
    • getContentHtml

      public org.apache.ecs.Element getContentHtml(Object generationhandle, EntitySet es)
      Description copied from class: Input
      Implements the interface Arrangeable. It returns the html code that represents the active part of the input field, i.e. the field and the validation scripts
      Specified by:
      getContentHtml in interface Arrangeable
      Overrides:
      getContentHtml in class Input
      Parameters:
      generationhandle - The handle of the generation
      es - The EntitySet to which the element belongs
      Returns:
      The html code of the input field or null if the field don't have a graphical representation
    • setAttributes

      protected void setAttributes(org.apache.ecs.html.Input i, boolean ro)
    • getHtml

      public org.apache.ecs.Element getHtml(EntitySet es)
      Description copied from class: Input
      Returns the html of the Input element
      Overrides:
      getHtml in class Input
      Parameters:
      es - The EntitySet
      Returns:
      The html of the Input element
    • validate

      protected void validate(org.apache.ecs.html.Input i, EntitySet es, boolean ro)
      Overrides:
      validate in class Input
    • validateNotNull

      protected void validateNotNull(String name, Object value, boolean strong, Map arriving) throws ValidationException
      Overrides:
      validateNotNull in class Input
      Throws:
      ValidationException
    • validateConcreteValue

      protected void validateConcreteValue(String name, Object value, boolean strong, Map arriving) throws ValidationException
      Overrides:
      validateConcreteValue in class Input
      Throws:
      ValidationException
    • verifyUploadedFile

      @Deprecated(forRemoval=true, since="W3_2023") public static boolean verifyUploadedFile(UpFile upFile, String acceptedExtensions)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Verifies that the uploaded file has a content type that conforms to the rules defined by the "accept" attribute.
      If t's not possible to find the uploaded file's contentType or the contentTypes defined by the "accept" attribute, a validation will be carried out on the type of the uploaded file based on its extension.
      Parameters:
      upFile - The uploaded file to be validated.
      acceptedExtensions - A list of contentType and extensions, separated by comma, which define the file types that will be accepted.
      Returns:
      true if the UpFile it's valid, false otherwise.