javaserverfaces-spec-public
  1. javaserverfaces-spec-public
  2. JAVASERVERFACES_SPEC_PUBLIC-1073

Add file upload specific attributes to h:inputFile component tag

    Details

    • Type: New Feature New Feature
    • Status: Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: 2.0, 2.1
    • Fix Version/s: None
    • Component/s: Components/Renderers
    • Labels:
      None

      Description

      This issue serves as a proposal for enhancing the new h:inputFile component tag with additional attributes.

      The three attributes that I would like to propose are:

      • location: String indicating the directory that uploaded file should be copied to. If not specified, then the "location" specified in the Servlet 3.0 web.xml context parameter will be utilized.
      • maxFileSize: Integer representing the maximum number of bytes that the component will accept for an uploaded file. If not specified, then the "max-file-size" specified in the Servlet 3.0 web.xml context parameter will be utilized.
      • mimeTypes: Comma-delimited list of uploaded file mime types that are valid. If not specified, then all mime types are assumed to be valid.

        Activity

        Hide
        Neil Griffin added a comment -

        In the "What's new in JSF 2.2" presentation that Ed Burns gave at JavaOne 2012, he mentioned that h:inputFile can work with a standard JSF validator. So for the "maxFileSize" and "mimeTypes" attributes, perhaps it would be better to introduce a new f:validateFile component:

        <h:inputFile>
        <f:validateFile maxFileSize="1048576" mimeTypes="png,gif,jpg" />
        </h:inputFile>

        Show
        Neil Griffin added a comment - In the "What's new in JSF 2.2" presentation that Ed Burns gave at JavaOne 2012, he mentioned that h:inputFile can work with a standard JSF validator. So for the "maxFileSize" and "mimeTypes" attributes, perhaps it would be better to introduce a new f:validateFile component: <h:inputFile> <f:validateFile maxFileSize="1048576" mimeTypes="png,gif,jpg" /> </h:inputFile>
        Hide
        andy_bosch added a comment -

        I like that idea. Would definitly makes sense!

        Show
        andy_bosch added a comment - I like that idea. Would definitly makes sense!
        Hide
        muellermi added a comment - - edited

        What will happen if a file of same name exists in upload location?
        The web developer may hook into.

        I propose to add an additional attribute as hint to create a default behavior if not hooked in.

        overwrite=allow|deny|rename

        rename will append some chars to the filename (e.g. a simple count) to make it unique

        Show
        muellermi added a comment - - edited What will happen if a file of same name exists in upload location? The web developer may hook into. I propose to add an additional attribute as hint to create a default behavior if not hooked in. overwrite=allow|deny|rename rename will append some chars to the filename (e.g. a simple count) to make it unique
        Hide
        Neil Griffin added a comment -

        I think it is the case with every implementation of file upload that I have seen, that the file would be overwritten.

        Show
        Neil Griffin added a comment - I think it is the case with every implementation of file upload that I have seen, that the file would be overwritten.
        Hide
        muellermi added a comment -

        Hm, better to be a follower or on the cutting edge? Innovation lives from new ideas.
        BTW, most file explorers, FTP uploads etc. offers options to prevent or allow overwrite or to keep both versions (rename).

        Show
        muellermi added a comment - Hm, better to be a follower or on the cutting edge? Innovation lives from new ideas. BTW, most file explorers, FTP uploads etc. offers options to prevent or allow overwrite or to keep both versions (rename).
        Hide
        Ed Burns added a comment -

        Set priority to baseline ahead of JSF 2.3 triage. Priorities will be assigned accurately after this exercise.

        Show
        Ed Burns added a comment - Set priority to baseline ahead of JSF 2.3 triage. Priorities will be assigned accurately after this exercise.
        Hide
        Manfred Riem added a comment -

        Setting priority to Minor

        Show
        Manfred Riem added a comment - Setting priority to Minor
        Hide
        Neil Griffin added a comment -

        I recently implemented my idea with the new alloy:inputFile and alloy:validateFile tags in Liferay Faces. For more info, see the Showcase demo.

        Show
        Neil Griffin added a comment - I recently implemented my idea with the new alloy:inputFile and alloy:validateFile tags in Liferay Faces. For more info, see the Showcase demo .

          People

          • Assignee:
            Unassigned
            Reporter:
            Neil Griffin
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated: