I'm using the freshest snapshot directly from SVN.
Glassfish 3.1
Netbeans under Win7.
The bean doesn't get called.
I tried it with the <p:outputPanel> and without,
I also tried prependID="false", hoping it would help.
I also tried the filters in web.xml
No way. Please help !
Regards,
Holger
Here is the code :
Code: Select all
<h:body>
<h:form id="uploadformid" enctype="multipart/form-data">
<p:outputPanel id="uploadpanel">
<p:fileUpload id="fuploadid" value="#{fileUploadController.file}" mode="simple" allowTypes=".jpg,.png,.jpeg,.bmp,.gif" />
<p:commandButton id="uploadbuttonid" value="Submit" ajax="false" action="#{fileUploadController.upload1}"/>
</p:outputPanel>
</h:form>
</h:body>
Code: Select all
import java.io.Serializable;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.faces.bean.ManagedBean;
import org.primefaces.model.UploadedFile;
import javax.faces.bean.SessionScoped;
import org.primefaces.event.FileUploadEvent;
/**
*
* @author awahe
*/
@ManagedBean(name="fileUploadController")
@SessionScoped
public class FileUploadController implements Serializable {
private static final Logger logger = Logger.getLogger(FileUploadController.class.getName());
private UploadedFile file;
private String filename ="c:\\desert.jpg";
public FileUploadController() {
logger.info("------- FileUploadController : constructor");
}
public UploadedFile getFile() {
logger.info("------- FileUploadController : getFile");
return file;
}
public void setFile(UploadedFile file) {
logger.info("------- FileUploadController : setFile");
this.file = file;
}
public void handleFileUpload(FileUploadEvent event) {
try {
logger.entering(FileUploadController.class.getName(), "handleFileUpload");
String localfilepath = event.getFile().getFileName();
String remotefilepath = "/anon_ftp/pub/";
logger.log(Level.INFO, "------- FileUploadController : upload : {0}", localfilepath);
logger.exiting(FileUploadController.class.getName(), "handleFileUpload");
} catch (Exception e) {
logger.log(Level.SEVERE, "******* FileUploadController : handleFileUpload{0}", e.getMessage());
}
}
public void upload() {
String localfilepath = file.getFileName();
String remotefilepath = "/anon_ftp/pub/";
logger.log(Level.INFO, "------- FileUploadController : upload : {0}", localfilepath);
}
public void upload1() {
String remotefilepath = "/anon_ftp/pub/";
logger.log(Level.INFO, "------- FileUploadController : upload1 : {0}", getFilename());
}
/**
* @return the filename
*/
public String getFilename() {
return filename;
}
/**
* @param filename the filename to set
*/
public void setFilename(String filename) {
this.filename = filename;
}
}