You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Piotr Pikusa <Pi...@pbpolsoft.com.pl> on 2007/07/25 15:10:18 UTC
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 <Pi...@pbpolsoft.com.pl> 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
Re: [Trinidad] How to check if file exists using InputFile compon ent?
Posted by Adam Winer <aw...@gmail.com>.
This sounds like a bug - you should get setFile(null) called
on your bean.
-- Adam
On 7/25/07, Piotr Pikusa <Pi...@pbpolsoft.com.pl> wrote:
> 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 <Pi...@pbpolsoft.com.pl> 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
>