primefaces onadd侦听器fileupload不调用
在根据我的要求实现我自己的逻辑之前,我试图在警报框中显示每个文件。但它不起作用。
<h:head>
<script type="text/javascript">
function displayEachFile(file,callback){
alert(file);
}
</script>
</h:head>
<h:body>
<div class="card">
<h:form name="download">
<p:fileUpload value="#{fileBean.files}" mode="advanced" multiple="true" auto="true"
listener="#{fileBean.handleFileUpload}" widgetVar="hello" onAdd="displayEachFile"/>
</h:form>
</div>
</h:body>
</html>
I am trying to display the each file in alert box before i implements my own logic as per my requirements. But its not working.
<h:head>
<script type="text/javascript">
function displayEachFile(file,callback){
alert(file);
}
</script>
</h:head>
<h:body>
<div class="card">
<h:form name="download">
<p:fileUpload value="#{fileBean.files}" mode="advanced" multiple="true" auto="true"
listener="#{fileBean.handleFileUpload}" widgetVar="hello" onAdd="displayEachFile"/>
</h:form>
</div>
</h:body>
</html>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
文档更新: https:/ /组件/fileupload
onadd
有3个参数this,file,parackback
。运行示例:
pf-8657.zip
文件
,如果您决定可以添加您的调用回调
。例如:
您可以执行仅添加名为
primefaces.pdf
的文件之类的事情。Documentation Updated: https://primefaces.github.io/primefaces/11_0_0/#/components/fileupload
onAdd
has 3 paramsthis, file, callback
.Running example:
pf-8657.zip
This gives you the opportunity to inspect the
file
and if you decide its OK to add you callcallback
.For example:
You could do something like only add files named
primefaces.pdf
for example.