I've added a validator attribute to the inputFileUpload component, but it is
not fired unless I have a valid file specified. Here is what I have:
                        <t:inputFileUpload id="fileupload"
                                       accept="image/*"
                                       value="#{fileBean.uploadedFile}"
                                       storage="file"
                                       styleClass="fileUploadInput"
                                       required="true"
                                      
validator="#{fileBean.validateFileExistance}"
                                       maxlength="180"></t:inputFileUpload>

And in my backing bean I have:
public void validateFileExistance(FacesContext context, UIComponent
toValidate,Object rcvRecord)throws Exception{
                FacesMessage message = new FacesMessage("Inside 
validateFileExistance");
                FacesContext facesContext = FacesContext.getCurrentInstance();
                
facesContext.addMessage(toValidate.getClientId(context),message);
                ...

        }

Any ideas?




David Delbecq-2 wrote:
> 
> You could add a custom validator that check the length of the uploaded
> file?
> jorge08 a écrit :
>>      
>> I am using the inputFileUpload Tomahawk component to upload files.
>> Everything works great except when the user types the file path and file
>> name directly into the input field. If the file path is wrong or the file
>> does not exists, there is no error messages displayed. I would like to
>> display a message to the user that the file does not exists. Is there a
>> way
>> to validate if the file exists?
>>
>> <h:form id="form1" enctype="multipart/form-data">
>>      <h:panelGrid columns="2" columnClasses="label,value"
>> styleClass="form">
>>                              
>>      <h:outputLabel value="* File:" for="fileupload"
>> styleClass="formLabel"></h:outputLabel>
>>              <h:panelGroup>
>>                      <t:inputFileUpload id="fileupload"
>>                                     accept="image/*"
>>                                     value="#{fileBean.uploadedFile}"
>>                                     storage="file"
>>                                     styleClass="fileUploadInput"
>>                                     required="true"
>>                                     maxlength="180"></t:inputFileUpload>
>>                      <h:message id="msgFile" for="fileupload" 
>> showDetail="true"
>> errorClass="errorMessage" infoClass="infoMessage"
>> fatalClass="fatalMessage"
>> warnClass="warnMessage"/>
>>   
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/inputFileUpload-issue-when-file-does-not-exists-tp15892132p15950753.html
Sent from the MyFaces - Users mailing list archive at Nabble.com.

Reply via email to