2014-04-10 10 views
4

我有一個添加primefaces fileupload。通過p上傳文件時傳遞另一個輸入組件的值:fileUpload mode = advanced

<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> 

它看起來像這樣 date Improt Primefaces

我有兩個問題。 我怎樣才能使Fileupload更小。意思不是在洞頁面上寬嗎?

要從selectOneMenu獲得名稱,我必須點擊讀取按鈕(Lesen)。如果我點擊和上傳按鈕,我從SelectOneMenu(空)沒有任何信息。我必須在<p:fileUpload..中寫入ajax =「true」或從上載 - 按鈕中的selectOneMenu獲取信息嗎?

我在更新fileUpload update="Collection,messages"時從集合中編寫Id,但它並不解決我的問題。

回答

5

您可以使用fileUpload的onstart,它將調用remoteCommand來處理您的selectOneMenu並將其保存爲必須視圖範圍相同的bean的屬性。

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

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

對於文件上傳的寬度,可以使用下面的CSS:

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

希望這有助於。

+0

謝謝你的工作! – marius0114

+0

不客氣:) –