I am using <t:inputFileUpload />
control of the Tomahawk library with JSF1.1.
My Extension Filters and form are set accordingly to allow a file of max-size 3 MB to be uploaded. But the problem is if a File is more than 3 MB the form doesnt get submitted but is shown again , and i cant set any <h:message>
for it .
So how do i tell the User the file upload has failed.
I have tried keeping <h:messages globalOnly="true"
but nothing gets shown.
I have followed BalusC blog post for setting up my uploads.
The exception detail is available in EL by
#{requestScope['org.apache.myfaces.custom.fileupload.exception']}
So, adding the following component to the page should do it
<h:outputText value="File upload failed! #{requestScope['org.apache.myfaces.custom.fileupload.exception']}"
styleClass="error" rendered="#{not empty requestScope['org.apache.myfaces.custom.fileupload.exception']}" />
You could eventually create a PhaseListener
which turns it into a FacesMessage
. Do the following in beforePhase()
of PhaseId.RENDER_RESPONSE
Object fileuploadException = requestMap.get("org.apache.myfaces.custom.fileupload.exception");
if (fileuploadException != null) {
facesContext.addMessage(null, new FacesMessage("File upload failed! " + fileuploadException));
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With