[JAVASERVERFACES_SPEC_PUBLIC-1206] required attribute is not enforced for inputFile Created: 08/Jul/13  Updated: 13/Aug/14

Status: Open
Project: javaserverfaces-spec-public
Component/s: Components/Renderers
Affects Version/s: 2.2
Fix Version/s: None

Type: Bug Priority: Major
Reporter: jasonzhang2002gmailcom Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

glassfish 4.0, Firefox


Issue Links:
Related
is related to JAVASERVERFACES-2923 required attribute is not enforced fo... Closed
Tags: file, file_upload, require

 Description   

When I select file at browser or not, I always have a part at server side. If no file is selected, the Part.size is zero.



 Comments   
Comment by Manfred Riem [ 08/Jul/13 ]

Can you please supply an example that reproduces the problem?

Comment by jasonzhang2002gmailcom [ 09/Jul/13 ]

This can be reproduced easily.


@RequestScoped
@Named
public class Test
{
	Part file;
	String str;
	public String getStr()
	{
		return str;
	}
	public void setStr(String str)
	{
		this.str = str;
	}
	public Part getFile()
	{
		return file;
	}
	public void setFile(Part file)
	{
		this.file = file;
	}
	public String save()
	{
		System.out.println("save is called");
		return null;
	}
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://xmlns.jcp.org/jsf/html"
	xmlns:f="http://xmlns.jcp.org/jsf/core"
	xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
	xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
	
<h:body>
	<h:messages>
	</h:messages>
	<h:form enctype="multipart/form-data">
		<h:inputFile value="#{test.file}" id="file" required="true"></h:inputFile>
		<h:inputText value="#{test.str}" id="string" required="true"></h:inputText>
		<h:commandButton value="submit" action="#{test.save}">
		</h:commandButton>
	</h:form>
</h:body>
</html>
Comment by Ed Burns [ 09/Jul/13 ]

Manfred and I investigated this and determined that UIInput.isEmpty() doesn't correctly handle this case when there is a Part that is empty.

UIInput.isEmpty() was added in support of JAVASERVERFACES_SPEC_PUBLIC-426.

Comment by Ed Burns [ 01/Aug/14 ]

Set priority to baseline ahead of JSF 2.3 triage. Priorities will be assigned accurately after this exercise.





[JAVASERVERFACES-2923] required attribute is not enforced for inputFile Created: 09/Jul/13  Updated: 17/Jul/13  Resolved: 17/Jul/13

Status: Closed
Project: javaserverfaces
Component/s: None
Affects Version/s: 2.2.0, 2.2.1
Fix Version/s: 2.2.2

Type: Bug Priority: Major
Reporter: jasonzhang2002gmailcom Assignee: Manfred Riem
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

glassfish 4.0, Firefox


Attachments: Text File changebundle.txt     Text File changebundle.txt     Zip Archive newfiles.zip    
Issue Links:
Related
is related to JAVASERVERFACES_SPEC_PUBLIC-1206 required attribute is not enforced fo... Open
Tags: file, file_upload, require

 Description   

When I select file at browser or not, I always have a part at server side. If no file is selected, the Part.size is zero.



 Comments   
Comment by Manfred Riem [ 10/Jul/13 ]

Applied to 2.2 branch,

svn commit -m "Fixes https://java.net/jira/browse/JAVASERVERFACES-2923, r=rogerk, make sure the required attribute on h:inputFile works"
Sending jsf-ri\src\main\java\com\sun\faces\renderkit\html_basic\FileRenderer.java
Deleting test\agnostic\facelets\html\nb-configuration.xml
Sending test\agnostic\facelets\html\pom.xml
Adding test\agnostic\facelets\html\src\main\resources
Adding test\agnostic\facelets\html\src\main\webapp\inputFileRequired.xhtml
Adding test\agnostic\facelets\html\src\test\java\com\sun\faces\test\agnostic\facelets\html\Issue2923IT.java
Transmitting file data ....
Committed revision 12080.

Comment by Manfred Riem [ 15/Jul/13 ]

Investigate problem with Tomcat

Comment by Manfred Riem [ 17/Jul/13 ]

Applied to 2.2 branch,

svn commit -m "Fixes https://java.net/jira/browse/JAVASERVERFACES-2923, make sure the test does not rely on CDI"
Sending test\agnostic\facelets\html\src\main\java\com\sun\faces\test\agnostic\facelets\html\FileUploadBean.java
Deleting test\agnostic\facelets\html\src\main\webapp\WEB-INF\beans.xml
Sending test\agnostic\facelets\html\src\main\webapp\inputFileRequired.xhtml
Transmitting file data ..
Committed revision 12112.





Generated at Sun Aug 28 13:46:51 UTC 2016 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.