You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Kostas Karadamoglou <ka...@yahoo.gr> on 2005/04/28 21:32:18 UTC
Questions about x:inputFileUpload
Hi, I would like to use the x:inputFileUpload but I don't know how
What I have already done is only the filter in the web xml file.
I want to ask you some specific questions
1) Which is the absolute path of the directory that sotes the uploaded
files? (Considering that in the web.xml I define a relative path)
2) What should be the type of the attribute that is binded with the
value parameter of the x:inputFileUpload?
3)Where can I find more information about using the x:inputFileUpload?
Thank you in advance, Kostas
Re: Questions about x:inputFileUpload
Posted by Jaroslav Rychna <ja...@centrum.cz>.
You must also set form to right encoding for uploading files:
<h:form enctype="multipart/form-data">
jarin
Kostas Karadamoglou napsal(a):
> I tried to do it like the example but myfaces does not access the setter
> of the property, therefore the attribute is always null.
> What do I do wrong?
>
> Here is my code...
> <h:form>
> <x:inputFileUpload id="fileupload"
> value="#{uploader.upFile}"
> accept="text/xml"
> storage="file"
> required="true"/>
> <h:commandButton
> action="#{uploader.addXmlFile}" value="Upload"/>
> </h:form>
> and...
>
> public class Uploader {
> private UploadedFile upFile=null;
> /** Creates a new instance of Uploader */
> public Uploader() {
> }
>
> public UploadedFile getUpFile() {
> return upFile;
> }
> public String addXmlFile(){
> //this.upFile.getContentType();
> return "";
> }
>
> public void setUpFile(UploadedFile upFile) {
> this.upFile = upFile;
> }
> }
>
> David Tashima wrote:
>
>> Ah, yeah, I think I got it from the 1.0.8 examples.
>>
>> Here is some version of it...
>>
>> Dave
>>
>>
>> On 4/28/05, Kostas Karadamoglou <ka...@yahoo.gr> wrote:
>>
>>
>>> Unfortunately I cannot find the backing bean of the fileUpload example
>>> in the cvs
>>> do you know where can I find it?
>>>
>>> David Tashima wrote:
>>>
>>>
>>>
>>>> It puts it into a myfaces UploadedFile (which should be a property on
>>>> your backing bean).. you have to do the file IO saving part yourself.
>>>>
>>>> Check out the fileupload.jsp sample in the myfaces example directory,
>>>> that's how I managed to figure it out (the docs are not so good).
>>>>
>>>> -Dave
>>>>
>>>> On 4/28/05, Kostas Karadamoglou <ka...@yahoo.gr> wrote:
>>>>
>>>>
>>>>
>>>>
>>>>> Hi, I would like to use the x:inputFileUpload but I don't know how
>>>>>
>>>>> What I have already done is only the filter in the web xml file.
>>>>>
>>>>> I want to ask you some specific questions
>>>>>
>>>>> 1) Which is the absolute path of the directory that sotes the uploaded
>>>>> files? (Considering that in the web.xml I define a relative path)
>>>>> 2) What should be the type of the attribute that is binded with the
>>>>> value parameter of the x:inputFileUpload?
>>>>> 3)Where can I find more information about using the x:inputFileUpload?
>>>>>
>>>>> Thank you in advance, Kostas
>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>
>>>
>
>
>
>
Re: Questions about x:inputFileUpload
Posted by David Tashima <da...@gmail.com>.
Check:
1) your filter is correct
2) your action should look like the action in the example file (I
honestly have no idea what these really do, but they look awfully
important):
FacesContext facesContext = FacesContext.getCurrentInstance();
facesContext.getExternalContext().getApplicationMap().put("fileupload_bytes",
_upFile.getBytes());
facesContext.getExternalContext().getApplicationMap().put("fileupload_type",
_upFile.getContentType());
facesContext.getExternalContext().getApplicationMap().put("fileupload_name",
_upFile.getName());
On 4/28/05, Kostas Karadamoglou <ka...@yahoo.gr> wrote:
> I tried to do it like the example but myfaces does not access the setter
> of the property, therefore the attribute is always null.
> What do I do wrong?
>
> Here is my code...
> <h:form>
> <x:inputFileUpload id="fileupload"
> value="#{uploader.upFile}"
> accept="text/xml"
> storage="file"
> required="true"/>
> <h:commandButton
> action="#{uploader.addXmlFile}" value="Upload"/>
> </h:form>
> and...
>
> public class Uploader {
>
> private UploadedFile upFile=null;
>
> /** Creates a new instance of Uploader */
> public Uploader() {
> }
>
> public UploadedFile getUpFile() {
> return upFile;
> }
>
> public String addXmlFile(){
> //this.upFile.getContentType();
> return "";
> }
>
> public void setUpFile(UploadedFile upFile) {
> this.upFile = upFile;
> }
> }
>
> David Tashima wrote:
>
> >Ah, yeah, I think I got it from the 1.0.8 examples.
> >
> >Here is some version of it...
> >
> >Dave
> >
> >
> >On 4/28/05, Kostas Karadamoglou <ka...@yahoo.gr> wrote:
> >
> >
> >>Unfortunately I cannot find the backing bean of the fileUpload example
> >>in the cvs
> >>do you know where can I find it?
> >>
> >>David Tashima wrote:
> >>
> >>
> >>
> >>>It puts it into a myfaces UploadedFile (which should be a property on
> >>>your backing bean).. you have to do the file IO saving part yourself.
> >>>
> >>>Check out the fileupload.jsp sample in the myfaces example directory,
> >>>that's how I managed to figure it out (the docs are not so good).
> >>>
> >>>-Dave
> >>>
> >>>On 4/28/05, Kostas Karadamoglou <ka...@yahoo.gr> wrote:
> >>>
> >>>
> >>>
> >>>
> >>>>Hi, I would like to use the x:inputFileUpload but I don't know how
> >>>>
> >>>>What I have already done is only the filter in the web xml file.
> >>>>
> >>>>I want to ask you some specific questions
> >>>>
> >>>>1) Which is the absolute path of the directory that sotes the uploaded
> >>>>files? (Considering that in the web.xml I define a relative path)
> >>>>2) What should be the type of the attribute that is binded with the
> >>>>value parameter of the x:inputFileUpload?
> >>>>3)Where can I find more information about using the x:inputFileUpload?
> >>>>
> >>>>Thank you in advance, Kostas
> >>>>
> >>>>
> >>>>
> >>>>
> >>>>
> >>>
> >>>
> >>>
> >>
> >>
>
>
Re: Questions about x:inputFileUpload
Posted by Kostas Karadamoglou <ka...@yahoo.gr>.
I tried to do it like the example but myfaces does not access the setter
of the property, therefore the attribute is always null.
What do I do wrong?
Here is my code...
<h:form>
<x:inputFileUpload id="fileupload"
value="#{uploader.upFile}"
accept="text/xml"
storage="file"
required="true"/>
<h:commandButton
action="#{uploader.addXmlFile}" value="Upload"/>
</h:form>
and...
public class Uploader {
private UploadedFile upFile=null;
/** Creates a new instance of Uploader */
public Uploader() {
}
public UploadedFile getUpFile() {
return upFile;
}
public String addXmlFile(){
//this.upFile.getContentType();
return "";
}
public void setUpFile(UploadedFile upFile) {
this.upFile = upFile;
}
}
David Tashima wrote:
>Ah, yeah, I think I got it from the 1.0.8 examples.
>
>Here is some version of it...
>
>Dave
>
>
>On 4/28/05, Kostas Karadamoglou <ka...@yahoo.gr> wrote:
>
>
>>Unfortunately I cannot find the backing bean of the fileUpload example
>>in the cvs
>>do you know where can I find it?
>>
>>David Tashima wrote:
>>
>>
>>
>>>It puts it into a myfaces UploadedFile (which should be a property on
>>>your backing bean).. you have to do the file IO saving part yourself.
>>>
>>>Check out the fileupload.jsp sample in the myfaces example directory,
>>>that's how I managed to figure it out (the docs are not so good).
>>>
>>>-Dave
>>>
>>>On 4/28/05, Kostas Karadamoglou <ka...@yahoo.gr> wrote:
>>>
>>>
>>>
>>>
>>>>Hi, I would like to use the x:inputFileUpload but I don't know how
>>>>
>>>>What I have already done is only the filter in the web xml file.
>>>>
>>>>I want to ask you some specific questions
>>>>
>>>>1) Which is the absolute path of the directory that sotes the uploaded
>>>>files? (Considering that in the web.xml I define a relative path)
>>>>2) What should be the type of the attribute that is binded with the
>>>>value parameter of the x:inputFileUpload?
>>>>3)Where can I find more information about using the x:inputFileUpload?
>>>>
>>>>Thank you in advance, Kostas
>>>>
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>
>>
Re: Questions about x:inputFileUpload
Posted by David Tashima <da...@gmail.com>.
Ah, yeah, I think I got it from the 1.0.8 examples.
Here is some version of it...
Dave
On 4/28/05, Kostas Karadamoglou <ka...@yahoo.gr> wrote:
> Unfortunately I cannot find the backing bean of the fileUpload example
> in the cvs
> do you know where can I find it?
>
> David Tashima wrote:
>
> >It puts it into a myfaces UploadedFile (which should be a property on
> >your backing bean).. you have to do the file IO saving part yourself.
> >
> >Check out the fileupload.jsp sample in the myfaces example directory,
> >that's how I managed to figure it out (the docs are not so good).
> >
> >-Dave
> >
> >On 4/28/05, Kostas Karadamoglou <ka...@yahoo.gr> wrote:
> >
> >
> >>Hi, I would like to use the x:inputFileUpload but I don't know how
> >>
> >>What I have already done is only the filter in the web xml file.
> >>
> >>I want to ask you some specific questions
> >>
> >>1) Which is the absolute path of the directory that sotes the uploaded
> >>files? (Considering that in the web.xml I define a relative path)
> >>2) What should be the type of the attribute that is binded with the
> >>value parameter of the x:inputFileUpload?
> >>3)Where can I find more information about using the x:inputFileUpload?
> >>
> >>Thank you in advance, Kostas
> >>
> >>
> >>
> >
> >
> >
>
>
Re: Questions about x:inputFileUpload
Posted by Kostas Karadamoglou <ka...@yahoo.gr>.
Unfortunately I cannot find the backing bean of the fileUpload example
in the cvs
do you know where can I find it?
David Tashima wrote:
>It puts it into a myfaces UploadedFile (which should be a property on
>your backing bean).. you have to do the file IO saving part yourself.
>
>Check out the fileupload.jsp sample in the myfaces example directory,
>that's how I managed to figure it out (the docs are not so good).
>
>-Dave
>
>On 4/28/05, Kostas Karadamoglou <ka...@yahoo.gr> wrote:
>
>
>>Hi, I would like to use the x:inputFileUpload but I don't know how
>>
>>What I have already done is only the filter in the web xml file.
>>
>>I want to ask you some specific questions
>>
>>1) Which is the absolute path of the directory that sotes the uploaded
>>files? (Considering that in the web.xml I define a relative path)
>>2) What should be the type of the attribute that is binded with the
>>value parameter of the x:inputFileUpload?
>>3)Where can I find more information about using the x:inputFileUpload?
>>
>>Thank you in advance, Kostas
>>
>>
>>
>
>
>
Re: Questions about x:inputFileUpload
Posted by David Tashima <da...@gmail.com>.
It puts it into a myfaces UploadedFile (which should be a property on
your backing bean).. you have to do the file IO saving part yourself.
Check out the fileupload.jsp sample in the myfaces example directory,
that's how I managed to figure it out (the docs are not so good).
-Dave
On 4/28/05, Kostas Karadamoglou <ka...@yahoo.gr> wrote:
> Hi, I would like to use the x:inputFileUpload but I don't know how
>
> What I have already done is only the filter in the web xml file.
>
> I want to ask you some specific questions
>
> 1) Which is the absolute path of the directory that sotes the uploaded
> files? (Considering that in the web.xml I define a relative path)
> 2) What should be the type of the attribute that is binded with the
> value parameter of the x:inputFileUpload?
> 3)Where can I find more information about using the x:inputFileUpload?
>
> Thank you in advance, Kostas
>