1
我試圖在我的<p:fileUpload>
中進行驗證。當用戶上傳時沒有放置任何文件,他會得到一條錯誤消息。我正在使用mode="simple"
和required="true"
,但required="true"
不起作用。FileUpload required =「true」在PrimeFaces中不起作用
P.S:我需要使用mode="simple"
,因爲我需要<p:commandButton>
才能提交其他數據。
<p:panelGrid columns="2">
<h:outputLabel id="image" value="Select Image: *" />
<p:fileUpload value="#{Jcalendar.file}" mode="simple"
allowTypes="/(\.|\/)(gif|jpe?g|png)$/"
required="true"
requiredMessage="File not selected !!"/>
<f:facet name="footer">
<p:commandButton value="Submit"
ajax="false"
action="#{Jcalendar.Upload}"
update=":form:msgs" />
</f:facet>
</p:panelGrid>
包含您自己的自定義驗證程序的驗證程序不能使用'
'。 – Tiny
@Tiny你能告訴我怎麼做?我是新來的primefaces – Moodi1409
除了把驗證邏輯放入''的監聽器(或者可能是sonewhere)中,除了一些繁瑣的黑客/自制的重新編譯器之外,沒有其他可以完成。 [見例如](http://stackoverflow.com/q/13865136/1391249)(和[也許](http://stackoverflow.com/q/22659268/1391249))。 –
Tiny