【发布时间】:2025-12-04 17:55:01
【问题描述】:
我有一个添加 primefaces 文件上传。
<h:form id="form" enctype="multipart/form-data">
<h:selectOneMenu id="Collection" value="#{imputData.collList.currentColl}">
<f:selectItems value="#{imputData.collList.collList}" />
</h:selectOneMenu>
<p:fileUpload id="fileUpload" label="Durchsuchen" uploadLabel="Upload" cancelLabel="zurück" fileUploadListener="#{imputData.handleFileUpload}" mode="advanced" dragDropSupport="true" update="Collection,messages" sizeLimit="100000" allowTypes="/(\.|\/)(txt|cvs)$/" />
<p:growl id="messages" showDetail="true"/>
<h:commandButton id="read" action="#{imputData.imput}" value="#{msgs.read}"/>
</h:form>
看起来像这样
我有两个问题。 我怎样才能使文件上传更小。意思是不超过孔页宽?
要从 selectOneMenu 中获取名称,我必须点击阅读按钮 (Lesen)。如果我点击上传按钮,我不会从 SelectOneMenu (null) 获得任何信息。我必须在<p:fileUpload.. 中写 ajax="true" 还是从上传按钮中的 selectOneMenu 获取信息?
我在 fileUpload update="Collection,messages" 的更新中写入了集合中的 ID,但这并没有解决我的问题。
【问题讨论】:
标签: jsf file-upload jsf-2 primefaces