mar*_*114 4 jsf file-upload primefaces jsf-2
我有一个添加primefaces fileupload.
<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>
Run Code Online (Sandbox Code Playgroud)
看起来像这样

我有两个问题.我怎样才能使Fileupload更小.孔页面意味着不宽?
要从selectOneMenu获取名称,我必须点击阅读按钮(Lesen).如果我点击上传按钮,我得不到SelectOneMenu的信息(null).我必须在<p:fileUpload..或者某事中写一个ajax ="true" 来从上传按钮中的selectOneMenu获取信息吗?
我在fileUpload的更新中从Collection中写了Id,update="Collection,messages"但它并没有解决我的问题.
您可以使用onstartfileUpload,它将调用remoteCommand来处理您的selectOneMenu并将其保存为必须视图范围的同一bean的属性.
<p:fileUpload id="fileUpload" mode="advanced" onstart="submitCollection()" />
<p:remoteCommand name="submitCollection" process="@this Collection" />
Run Code Online (Sandbox Code Playgroud)
至于fileUpload的宽度,您可以使用以下css:
.ui-fileupload {
width: 400px;//change the px into what fits you
}
Run Code Online (Sandbox Code Playgroud)
希望这可以帮助.
| 归档时间: |
|
| 查看次数: |
1310 次 |
| 最近记录: |