我正在尝试使用PrimeFaces上传文件,但fileUploadListener上传完成后不会调用该方法.
这是观点:
<h:form>
<p:fileUpload fileUploadListener="#{fileUploadController.handleFileUpload}"
mode="advanced"
update="messages"
sizeLimit="100000"
allowTypes="/(\.|\/)(gif|jpe?g|png)$/"/>
<p:growl id="messages" showDetail="true"/>
</h:form>
Run Code Online (Sandbox Code Playgroud)
还有豆子:
@ManagedBean
@RequestScoped
public class FileUploadController {
public void handleFileUpload(FileUploadEvent event) {
FacesMessage msg = new FacesMessage("Succesful", event.getFile().getFileName() + " is uploaded.");
FacesContext.getCurrentInstance().addMessage(null, msg);
}
}
Run Code Online (Sandbox Code Playgroud)
我已经在方法上放置了一个断点,但它从未调用过.当使用mode="simple"和时ajax="false",它已被调用,但我希望它在高级模式下工作.我正在使用Netbeans和Glassfish 3.1.
我正在尝试像primefaces用户指南中记录的那样工作,并在那里创建了一些帖子.
环境是:javaee full + jpa + jsf 2.2 + primefaces 4 + glassfish v4
我再次发帖,因为我已经尝试了我在网上找到的每一个样本和建议,都没有成功.
我能够使用:event.getFile.getFileName获取文件上传名称,但内容始终为null
- - - - - - -更新 - - - - - - - - - - - - - -
我的xhtml页面:
<h:form enctype="multipart/form-data">
<p:outputLabel value="La photo :"/>
<p:fileUpload fileUploadListener="#{personController.upload}"
mode="advanced"
update="messages"
sizeLimit="100000"
allowTypes="/(\.|\/)(gif|jpe?g|png)$/"/>
<p:growl id="messages" showDetail="true"/>
</h:form>
Run Code Online (Sandbox Code Playgroud)
我的托管bean:
@Named(value = "personController")
@SessionScoped
public class PersonController implements Serializable {
/**
* Creates a new instance of PersonController
*/
@Inject
private PersonneFacade …Run Code Online (Sandbox Code Playgroud) file-upload ×2
java ×2
jsf ×2
primefaces ×2
bytearray ×1
inputstream ×1
jsf-2 ×1
managed-bean ×1