You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Vojtěch Zavřel <vo...@aura.cz> on 2015/04/14 16:37:08 UTC
h:inputFile required attribute don't work
Hi,
it seems to me, that the required attribute of h:inputFile is not
working. The reason is, that there is always an instance of
javax.servlet.http.Part in submitted value and there should be something
like part.getSize() <= 0 in getConvertedValue() or maybe overriden
isEmpty method of UIInput class where is basic types emptiness check.
You can repeat that problem just on a simple form with h:inputFile, with
required="true" without any validator.
<h:form id="inputForm" enctype="multipart/form-data">
<!-- inputFile tag to upload file -->
Upload File
<h:inputFile id="file"
label="file"
value="#{inputBean.part}"
required="true"
requiredMessage="File not selected !!">
</h:inputFile>
<h:message style="color: red" for="file" /><br />
<h:commandButton id="submit"
action="#{inputBean.uploadFile}"
value="upload file" /><br />
</h:form>
Testing on Tomcat 7.0.59, MyFaces 2.2.6
--
Mgr. Vojtěch Zavřel
System architect
AURA, s.r.o.
Úvoz 499/56
602 00 Brno
Czech Republic
Tel.: +420 544 508 181
Fax: +420 544 508 112
E-mail: vojtech.zavrel@aura.cz
Internet: www.aura.cz
Certifikace ISO 9001, ISO 8000, ISO 27001 a ČOS 051622 (AQAP 2110)
Re: h:inputFile required attribute don't work
Posted by Mike Kienenberger <mk...@gmail.com>.
My apologies for the late reply.
Any chance you can create an issue for this in our JIRA issue tracker
and submit a patch with a fix?
On Tue, Apr 14, 2015 at 10:37 AM, Vojtěch Zavřel <vo...@aura.cz> wrote:
> Hi,
> it seems to me, that the required attribute of h:inputFile is not working.
> The reason is, that there is always an instance of javax.servlet.http.Part
> in submitted value and there should be something like part.getSize() <= 0 in
> getConvertedValue() or maybe overriden isEmpty method of UIInput class where
> is basic types emptiness check.
>
> You can repeat that problem just on a simple form with h:inputFile, with
> required="true" without any validator.
>
> <h:form id="inputForm" enctype="multipart/form-data">
>
> <!-- inputFile tag to upload file -->
> Upload File
> <h:inputFile id="file"
> label="file"
> value="#{inputBean.part}"
> required="true"
> requiredMessage="File not selected !!">
> </h:inputFile>
> <h:message style="color: red" for="file" /><br />
>
> <h:commandButton id="submit"
> action="#{inputBean.uploadFile}"
> value="upload file" /><br />
> </h:form>
>
> Testing on Tomcat 7.0.59, MyFaces 2.2.6
>
> --
> Mgr. Vojtěch Zavřel
> System architect
> AURA, s.r.o.
> Úvoz 499/56
> 602 00 Brno
> Czech Republic
>
> Tel.: +420 544 508 181
> Fax: +420 544 508 112
> E-mail: vojtech.zavrel@aura.cz
> Internet: www.aura.cz
> Certifikace ISO 9001, ISO 8000, ISO 27001 a ČOS 051622 (AQAP 2110)
>