Hi Wolfgang,
did you add extensionsFilter to your web.xml?(see below)
mfg
christoph
filter configuration:
<filter>
<filter-name>extensionsFilter</filter-name>
<filter-class>org.apache.myfaces.webapp.filter.ExtensionsFilter
</filter-class>
<init-param>
<param-name>uploadMaxFileSize</param-name>
<param-value>100m</param-value>
<description>Set the size limit for uploaded files.
Format: 10 - 10 bytes
10k - 10 KB
10m - 10 MB
1g - 1 GB
</description>
</init-param>
<init-param>
<param-name>uploadThresholdSize</param-name>
<param-value>100k</param-value>
<description>Set the threshold size - files
below this limit are stored in memory, files above
this limit are stored on disk.
Format: 10 - 10 bytes
10k - 10 KB
10m - 10 MB
1g - 1 GB
</description>
</init-param>
</filter>
<filter-mapping>
<filter-name>extensionsFilter</filter-name>
<url-pattern>*.jsf</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>extensionsFilter</filter-name>
<url-pattern>/faces/*</url-pattern>
</filter-mapping>
On 9/6/07, Wolfgang <[EMAIL PROTECTED]> wrote:
>
> Hi Christoph,
>
> I tried to get the upload running since 2hours...
> Now I used this example:
> http://www.irian.at/myfaces/fileupload.jsf
> I copied it one by one, but I had to remove some stuff, because I got
> some errors.
> But the stuff I removed was just outputtext...
>
> I got the same nullpointer exception as ever :(
>
> But I think it can't be too hard to set up just a "simple" upload field.
>
> Given that I can't find any other good examples via google, I want to ask
> if you know a good website which shows step by step the creation of such
> a upload field?
>
> Thanks Wolfgang
> > Hi Wolfgang,
> >
> > this means that you already have a h:form-tag in your page,
> > surrounding the one with id "upload".
> > You can either remove this form and switch the enctype on the outer one.
> > Or if the form is included in a template, and you don't want to have
> > the enctype "multipart/form-data" for all your views you can set the
> > enctype dynamically via a binding.
> >
> > public HtmlForm getForm(){
> > HtmlForm form = (HtmlForm)
> > getApplication().createComponent("javax.faces.HtmlForm");
> > String currentViewId =
> > FacesContext.getCurrentInstance().getViewRoot().getViewId();
> > if(currentViewId.equals("/some_upload_form.xhtml")) {
> > form.setEnctype("multipart/form-data");
> > }
> > return form;
> > }
> >
> > cheers,
> > Christoph
> >
> >
> >
> > On 9/6/07, *Wolfgang* <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>>
> wrote:
> >
> > Hi sorry forgot to put the new html code inside.
> > Here it is:
> >
> > <h:form id="upload" enctype="multipart/form-data">
> >
> > <t:inputFileUpload
> > id="myUploadedFile"
> > storage="file"
> > accept="image/*"
> > styleClass="myStyle"
> > value="#{ home.uploadFile}"/>
> >
> > <h:commandButton
> > actionListener="#{home.upload}"/>
> >
> > </h:form>
> >
> > > Hi Wolfgang,
> > >
> > > make sure that the surrounding h:form has
> > enctype="multipart/form-data".
> > >
> > > cheers,
> > > christoph
> > >
> > > On 9/6/07, *Wolfgang* <[EMAIL PROTECTED]
> > <mailto:[EMAIL PROTECTED]> <mailto:[EMAIL PROTECTED]
> > <mailto:[EMAIL PROTECTED]>>> wrote:
> > >
> > > Hi,
> > >
> > > I tried to upload a File but I always got a
> > NullPointerException,
> > > because the uploadFile.getBytes(),
> > uploadFile.getContentType() and
> > > uploadFile.getName()) are null.
> > >
> > > I don't understand why?!
> > >
> > > Cheers!
> > >
> > >
> > > private UploadedFile uploadFile;
> > >
> > >
> > > public void upload(ActionEvent evt) throws IOException
> > > {
> > > FacesContext facesContext =
> > FacesContext.getCurrentInstance();
> > >
> > > facesContext.getExternalContext
> > > ().getApplicationMap().put("fileupload_bytes",
> > > uploadFile.getBytes());
> > >
> > >
> > facesContext.getExternalContext
> ().getApplicationMap().put("fileupload_type",
> > > uploadFile.getContentType());
> > >
> > > facesContext.getExternalContext
> > > ().getApplicationMap().put("fileupload_name",
> > > uploadFile.getName());
> > >
> > > }
> > >
> > > // Getter and Setters
> > >
> > > public UploadedFile getUploadFile() {
> > > return uploadFile;
> > > }
> > >
> > > public void setUploadFile(UploadedFile uploadFile) {
> > > this.uploadFile = uploadFile;
> > > }
> > >
> > >
> > > <t:inputFileUpload
> > > id="myUploadedFile"
> > > storage="file"
> > > accept="image/*"
> > > styleClass="myStyle"
> > > value="#{home.uploadFile}"/>
> > >
> > > <h:commandButton actionListener="#{home.upload}"/>
> > >
> > >
> >
> >
>
>