/** @param fileName The name of the file */ public void setFileName(String fileName) { this.fileName = fileName; // we also need to keep the file upload bean in sync FacesContext ctx = FacesContext.getCurrentInstance(); FileUploadBean fileBean = (FileUploadBean) ctx.getExternalContext().getSessionMap().get(FileUploadBean.FILE_UPLOAD_BEAN_NAME); if (fileBean != null) { fileBean.setFileName(this.fileName); } }
/** @return Returns the name of the file */ public String getFileName() { // try and retrieve the file and filename from the file upload bean // representing the file we previously uploaded. FacesContext ctx = FacesContext.getCurrentInstance(); FileUploadBean fileBean = (FileUploadBean) ctx.getExternalContext().getSessionMap().get(FileUploadBean.FILE_UPLOAD_BEAN_NAME); if (fileBean != null) { this.file = fileBean.getFile(); this.fileName = fileBean.getFileName(); } return this.fileName; }