Hi Christoph,
I have embedded my xhtml code with the form tag, but now I got the
following error
which I always get when I use the form tag:
You should never nest HTML-forms. This leads to unpredictable behaviour in all
major browsers. You can use multiple forms on a page, but they may not be
nested!If you need to disable this check (on your own risk!) set the param
org.apache.myfaces.VALIDATE in your web.xml context parameters to false
I don't understand exactly what nested meens.
Does this meen I mustn't put more than one html tag in a form tag?
Do you think I should change the param. in the web.xml?
Thx Wolfgang
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]>> 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}"/>