本文介绍了当通过p:fileUpload mode = advanced上传文件时,传递另一个输入组件的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  

您可以使用fileUpload的 onstart 一个用于处理selectOneMenu的remoteCommand,并将其保存为必须视图范围相同的bean的属性。

 < p:fileUpload id =fileUploadmode =advancedonstart =submitCollection()/> 

< p:remoteCommand name =submitCollectionprocess =@ this Collection/>

至于fileUpload的宽度,可以使用下面的css:

  .ui-fileupload {
width:400px; //将px改成适合你的值
}

希望这有助于您。


i have a the add the 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>

It looks like this

I have two question.How can i made the Fileupload smaller. Mean not wide over the hole page?

To get the name from the selectOneMenu i must klick on the read-button (Lesen). If i klick und the upload-button i get no information from the SelectOneMenu (null). Must i write ajax="true" in the <p:fileUpload.. or something to get the Information from selectOneMenu in the upload-Button?

i write the Id from the Collection in the update of fileUpload update="Collection,messages" but it doesn't slove my problem.

解决方案

You can use the onstart of the fileUpload, which would call a remoteCommand to process your selectOneMenu and save it as property of the same bean which must be view scoped.

<p:fileUpload id="fileUpload" mode="advanced" onstart="submitCollection()" />

<p:remoteCommand name="submitCollection" process="@this Collection" />

As for the width of the fileUpload, you can use the following css:

.ui-fileupload {
   width: 400px;//change the px into what fits you
}

Hope this helps.

这篇关于当通过p:fileUpload mode = advanced上传文件时,传递另一个输入组件的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-02 16:01