primefaces: ValidateFile: with variable in sizeLimit not working

Describe the bug

If i use p:valiadteFile with a variable in sizeLimit (fileUploadView.size) it doesn’t consider it at runtime.

 <h:form id="frmTest">

			<p:growl id="growl" sticky="true" showDetail="true"/>

			<p:inputText value="#{fileUploadView.size}" >
				<p:ajax update="xx,input20" />
			</p:inputText>
			<h:outputText id="xx" value="#{fileUploadView.size}" />

			<p:fileUpload id="input20" update="growl" 
					  listener="#{fileUploadView.handleFileUpload}"
					  mode="advanced" dragDropSupport="true" auto="true" >
				<p:validateFile sizeLimit="#{fileUploadView.getSizeLimit(fileUploadView.size)}" allowTypes="/(\.|\/)(gif|jpeg|jpg|png)$/" />
			</p:fileUpload>

        </h:form>
@Named
@RequestScoped
public class FileUploadView {

	private UploadedFile file;
	private String size;

	public void upload() {
		if (file != null) {
			FacesMessage message = new FacesMessage("Successful", file.getFileName() + " is uploaded.");
			FacesContext.getCurrentInstance().addMessage(null, message);
		}
	}

	public void handleFileUpload(FileUploadEvent event) {
		FacesMessage message = new FacesMessage("Successful", event.getFile().getFileName() + " is uploaded.");
		FacesContext.getCurrentInstance().addMessage(null, message);
	}

	public UploadedFile getFile() {
		return file;
	}

	public void setFile(UploadedFile file) {
		this.file = file;
	}


	public String getSizeLimit(String limit) {
		if (limit != null) {
			return limit;
		}
		return "100000";
	}

	@PostConstruct
	public void init() {
		setSize("70000");
	}

	public String getSize() {
		return size;
	}

	public void setSize(String size) {
		this.size = size;
	}

}

Reproducer

No response

Expected behavior

No response

PrimeFaces edition

None

PrimeFaces version

14.0.2

Theme

No response

JSF implementation

Mojarra

JSF version

4.0

Java version

17

Browser(s)

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 17 (14 by maintainers)

Commits related to this issue

Most upvoted comments

IMO validator needs support for StateHelper like Components, thats whats missing in specs

We implemented it, @jungm could provide and we can migrate to it

not sure but the code in the behavior implements full-state saving, seems we didnt implement delta state here like MF does

maybe we should create a second issue about it