AnsweredAssumed Answered


Question asked by sjeek on Apr 12, 2006
Latest reply on Apr 13, 2006 by kevinr

I'm trying to upload files with just one button (so, the "upload" and the "finish" button together.)

Now, I made a copy of UploadFileServlet and worked with the copy.

This code works fine

// —————————————-
         StringBuilder builder = new StringBuilder();

               .getCurrentInstance(), bean.getFileName()));
         String mime = builder.toString();

         // set mimetype of content

         // set inline Edit if mimetype = HTML

         // Try and extract metadata from the file
         ContentReader cr = new FileContentReader(this.file);

         // create properties for content type
         Map<QName, Serializable> contentProps = new HashMap<QName, Serializable>(
               5, 1.0f);

         // if (Repository.extractMetadata(FacesContext.getCurrentInstance(),
         // cr, contentProps))
         // {
         addwiz.setAuthor((String) (contentProps
               .setTitle((String) (contentProps
         addwiz.setDescription((String) (contentProps
         // }

          if (addwiz.getTitle() == null)

But, now, I want to upload the files affcourse:

addwiz.quick(this.file, null);

public String quick(File fileContent, String strContent)
      String outcome = quicksaveContent(fileContent, strContent);
      // now we know the new details are in the repository, reset the
      // client side node representation so the new details are retrieved
      if (this.editMode)
      return outcome;

Now, in the saveContent, I always get a nullpointer at the FacesContext.getCurrentInstance()!
At the first, I get this exception also at the first code, but I made muy way around it.

someone told me that this problem could be that the FacesContext.getCurrentInstance() use a HTTP request and the Servlet not, so that's why I get the nullpointer, but here stops my knowlidge of java  :)

If you also can see in the first code i did
// if (Repository.extractMetadata(FacesContext.getCurrentInstance(),

so i would not have a nullpointer offcourse

so, if someone could help me?