How to upload the Files with JSf and Myfaces

Goutham's Avatar, Join Date: Jan 2007
Newbie Member
hi ,

i have used
Code:
     <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>
in web.xml file

Bean class
Code:
public class FileUploadForm
{
    private UploadedFile _upFile;
    private String _name = "";

    public UploadedFile getUpFile()
    {
        return _upFile;
    }

    public void setUpFile(UploadedFile upFile)
    {
        _upFile = upFile;
    }

    public String getName()
    {
        return _name;
    }

    public void setName(String name)
    {
        _name = name;
    }

    public String upload() throws IOException
    {
        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());
        return "ok";
    }

    public boolean isUploaded()
    {
        FacesContext facesContext = FacesContext.getCurrentInstance();
        return facesContext.getExternalContext().getApplicationMap().get
("fileupload_bytes")!=null;
    }

   public String saveStyle()
   {
     System.out.println("Hello from saveStyle");
     return "Hello from saveStyle";
   }

}
But it is showing Error as

cannot find symbol
[javac] symbol : class UploadedFile
[javac] private UploadedFile upFile;
can anybody Help in this Regard

Last edited by shabbir; 5Jan2007 at 09:39.. Reason: Code formating.
0
Goutham's Avatar, Join Date: Jan 2007
Newbie Member
Plz send Reply to this Query
0
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
Try using the code block for putting your code snippets in the post.

Also moved the thread from Introduce yourself to JSP forum.