primefaces: FileUpload: show function in client API doesn't work for the second time

** using client API FileUpload can’t call listener method ** Calling show function of FileUpload same as #5373

Environment:

  • PF Version: 10.0
  • JSF + version: Mojarra 2.2.19
  • Affected browsers: Safari Chrome may be any browser.

To Reproduce Steps to reproduce the behavior:

  1. Click on button ‘CSV Upload’
  2. Click on menu item ‘0’
  3. Chose some file
  4. Repeat these steps
  5. FileUpload doesn’t call listener method at twice

Expected behavior FileUpload should call listener method repeatedly

Example XHTML

<h:head/>
<h:body>
<f:view>
<h:form>
<p:growl id="growl"/>
<p:menuButton value="CSV Upload">
  <p:menuitem value="0" onstart="PF('upload0').show()"/>
  <p:menuitem value="1" onstart="PF('upload1').show()"/>
  <p:menuitem value="2" onstart="PF('upload2').show()"/>
  <p:menuitem value="3" onstart="PF('upload3').show()"/>
  <p:menuitem value="4" onstart="PF('upload4').show()"/>
  <p:menuitem value="5" onstart="PF('upload5').show()"/>
  <p:menuitem value="6" onstart="PF('upload6').show()"/>
  <p:menuitem value="7" onstart="PF('upload7').show()"/>
  <p:menuitem value="8" onstart="PF('upload8').show()"/>
  <p:menuitem value="9" onstart="PF('upload9').show()"/>
</p:menuButton>
<p:fileUpload widgetVar="upload0" auto="true" style="display:none;" listener="#{UploadTest.uploadCsv0}" update="growl"/>
<p:fileUpload widgetVar="upload1" auto="true" style="display:none;" listener="#{UploadTest.uploadCsv1}" update="growl"/>
<p:fileUpload widgetVar="upload2" auto="true" style="display:none;" listener="#{UploadTest.uploadCsv2}" update="growl"/>
<p:fileUpload widgetVar="upload3" auto="true" style="display:none;" listener="#{UploadTest.uploadCsv3}" update="growl"/>
<p:fileUpload widgetVar="upload4" auto="true" style="display:none;" listener="#{UploadTest.uploadCsv4}" update="growl"/>
<p:fileUpload widgetVar="upload5" auto="true" style="display:none;" listener="#{UploadTest.uploadCsv5}" update="growl"/>
<p:fileUpload widgetVar="upload6" auto="true" style="display:none;" listener="#{UploadTest.uploadCsv6}" update="growl"/>
<p:fileUpload widgetVar="upload7" auto="true" style="display:none;" listener="#{UploadTest.uploadCsv7}" update="growl"/>
<p:fileUpload widgetVar="upload8" auto="true" style="display:none;" listener="#{UploadTest.uploadCsv8}" update="growl"/>
<p:fileUpload widgetVar="upload9" auto="true" style="display:none;" listener="#{UploadTest.uploadCsv9}" update="growl"/>
</h:form>
</f:view>
</h:body>

Example Bean

@ManagedBean(name="UploadTest")
@ViewScoped
public class UploadTestManagedBean {
	public void uploadCsv0(FileUploadEvent event){uploadCsv(event.getFile(), 0);}
	public void uploadCsv1(FileUploadEvent event){uploadCsv(event.getFile(), 1);}
	public void uploadCsv2(FileUploadEvent event){uploadCsv(event.getFile(), 2);}
	public void uploadCsv3(FileUploadEvent event){uploadCsv(event.getFile(), 3);}
	public void uploadCsv4(FileUploadEvent event){uploadCsv(event.getFile(), 4);}
	public void uploadCsv5(FileUploadEvent event){uploadCsv(event.getFile(), 5);}
	public void uploadCsv6(FileUploadEvent event){uploadCsv(event.getFile(), 6);}
	public void uploadCsv7(FileUploadEvent event){uploadCsv(event.getFile(), 7);}
	public void uploadCsv8(FileUploadEvent event){uploadCsv(event.getFile(), 8);}
	public void uploadCsv9(FileUploadEvent event){uploadCsv(event.getFile(), 9);}
	public void uploadCsv(UploadedFile data, int fileId){
		FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "FileId:" + fileId, null));
	}
}

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 20 (18 by maintainers)

Commits related to this issue

Most upvoted comments

yeah please i think we could reset automatically somehow? update=@this is just a hack IMO

Actually update="@this growl" is even better. The fileUpload itself needs to be updated after to reset it.