Hi Piotr,

i don't know the tomahawk InputFile component, but maybe you can check
the uploaded filename?

In tobago we check the filename to determine if a file was uploaded:

 if (file == null || file.getName().length() == 0) {
          addErrorMessage(facesContext);
          setValid(false);
 }


Regards,
    Volker


2007/7/26, Piotr Pikusa <[EMAIL PROTECTED]>:
> In many toutorials about InputFile component (e.g on Oracle and Trinidad
> sites) there is if instruction to check if uploadFile is not null. But it
> would never be null, event if the file doesn't exist. Is it a bug in
> compoment? Is there any way to check file existence using InputFile
> component?
>
>
> -----Original Message-----
> From: Piotr Pikusa [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, July 25, 2007 3:10 PM
> To: 'MyFaces Discussion'
> Subject: RE: [Trinidad] How to check if file exists using InputFile compon
> ent?
>
>
> Unfotunately not. If the existing file is empty the getLength() method
> returns 0 too. So the problem isn't still solved.
>
>
> Matthias Wessendorf  wrote:
>
> hi piotr,
>
> the UploadedFile interfaces has a getLength() method
>
> it's 0, when the file isn't there..
>
> -M
>
> On 7/25/07, Piotr Pikusa <[EMAIL PROTECTED]> wrote:
> > Hey!
> >
> > As it is mentioned in the subject I wonder if there is any possibility to
> > check file existence.
> > I got this code on my jsp page:
> >
> > [code]
> >
> > <tr:inputFile
> >    required="true"
> >    rendered="true"
> >    label="Load File:"
> >    value="#{backingBean.file}"
> >  />
> > <af:commandButton
> >     text="#{"Button"}"
> >     action="#{backingBean.importFile}" />
> >
> > [/code]
> >
> > which bind the value to the file property. The type of file is UploadFile.
> > In backingBean I have this code:
> >
> > [code]
> >
> > UploadFile file;
> >
> > public void importFile(){
> >         if(file != null) {
> >                 doSomeAction();
> >         }
> >         else{
> >                 returnError();
> >         }
> > }
> >
> > public UploadedFile getFile() {
> >                 return file;
> >         }
> >
> > public void setFile(UploadedFile file) {
> >                 this.file = file;
> > }
> >
> > [/code]
> >
> > The point of the problem is that the file is never null, no matter if file
> > exists or not. If file doesn't exist the InputFile component doesn't
> return
> > null. The UploadFile doesn't have a method to check file existence.
> > So my question is when file property can be null. And how to check if file
> > exists using InputFile component and UploadFile object? (I cannot use
> other
> > type, but UploadFile).
> >
>
>
> --
> Matthias Wessendorf
>
> further stuff:
> blog: http://matthiaswessendorf.wordpress.com/
> mail: matzew-at-apache-dot-org
>

Reply via email to