You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lu...@apache.org on 2016/02/13 00:41:30 UTC
svn commit: r1730143 - in /myfaces/core/trunk/impl/src:
main/java/org/apache/myfaces/view/facelets/compiler/
main/java/org/apache/myfaces/view/facelets/el/
test/java/org/apache/myfaces/view/facelets/tag/jsf/html/
test/resources/org/apache/myfaces/view/...
Author: lu4242
Date: Fri Feb 12 23:41:29 2016
New Revision: 1730143
URL: http://svn.apache.org/viewvc?rev=1730143&view=rev
Log:
MYFACES-4031 Facelets does not render empty XHTML attribute
Added:
myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/jsf/html/testEmptyHtmlAttribute.xhtml
- copied, changed from r1730129, myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/jsf/html/testHtmlPassthrough1.xhtml
Modified:
myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/TextUnit.java
myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/el/ELText.java
myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/tag/jsf/html/HtmlTestCase.java
Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/TextUnit.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/TextUnit.java?rev=1730143&r1=1730142&r2=1730143&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/TextUnit.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/TextUnit.java Fri Feb 12 23:41:29 2016
@@ -310,7 +310,7 @@ final class TextUnit extends Compilation
String value = attrs[i].getValue();
this.buffer.append(' ').append(qname).append("=\"").append(value).append("\"");
- ELText txt = ELText.parse(value);
+ ELText txt = ELText.parseAllowEmptyString(value);
if (txt != null)
{
if (txt.isLiteral())
Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/el/ELText.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/el/ELText.java?rev=1730143&r1=1730142&r2=1730143&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/el/ELText.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/el/ELText.java Fri Feb 12 23:41:29 2016
@@ -461,6 +461,18 @@ public class ELText
{
return parse(null, null, in);
}
+
+ public static ELText parseAllowEmptyString(String in) throws ELException
+ {
+ if (in != null && in.length() == 0)
+ {
+ return new ELText(in);
+ }
+ else
+ {
+ return parse(null, null, in);
+ }
+ }
/**
* Factory method for creating a validated ELText instance. When an Expression is hit, it will use the
Modified: myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/tag/jsf/html/HtmlTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/tag/jsf/html/HtmlTestCase.java?rev=1730143&r1=1730142&r2=1730143&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/tag/jsf/html/HtmlTestCase.java (original)
+++ myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/tag/jsf/html/HtmlTestCase.java Fri Feb 12 23:41:29 2016
@@ -19,6 +19,7 @@
package org.apache.myfaces.view.facelets.tag.jsf.html;
+import java.io.StringWriter;
import javax.el.MethodExpression;
import javax.faces.component.ActionSource2;
import javax.faces.component.UIComponent;
@@ -35,6 +36,7 @@ import org.apache.myfaces.renderkit.html
import org.apache.myfaces.renderkit.html.HtmlFormRenderer;
import org.apache.myfaces.renderkit.html.HtmlGridRenderer;
import org.apache.myfaces.renderkit.html.HtmlTextRenderer;
+import org.apache.myfaces.test.mock.MockResponseWriter;
import org.apache.myfaces.view.facelets.FaceletTestCase;
import org.junit.Assert;
import org.junit.Test;
@@ -113,5 +115,21 @@ public class HtmlTestCase extends Facele
UIViewRoot root = facesContext.getViewRoot();
vdl.buildView(facesContext, root, "panelGrid.xml");
}
+
+ @Test
+ public void testEmptyHtml() throws Exception {
+ UIViewRoot root = facesContext.getViewRoot();
+ vdl.buildView(facesContext, root, "testEmptyHtmlAttribute.xhtml");
+
+ StringWriter sw = new StringWriter();
+ MockResponseWriter mrw = new MockResponseWriter(sw);
+ facesContext.setResponseWriter(mrw);
+
+ root.encodeAll(facesContext);
+ sw.flush();
+
+ Assert.assertTrue(sw.toString().contains("alt=\"\""));
+ }
+
}
Copied: myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/jsf/html/testEmptyHtmlAttribute.xhtml (from r1730129, myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/jsf/html/testHtmlPassthrough1.xhtml)
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/jsf/html/testEmptyHtmlAttribute.xhtml?p2=myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/jsf/html/testEmptyHtmlAttribute.xhtml&p1=myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/jsf/html/testHtmlPassthrough1.xhtml&r1=1730129&r2=1730143&rev=1730143&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/jsf/html/testHtmlPassthrough1.xhtml (original)
+++ myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/jsf/html/testEmptyHtmlAttribute.xhtml Fri Feb 12 23:41:29 2016
@@ -18,58 +18,10 @@
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:jsf="http://java.sun.com/jsf">
-<head jsf:id="idHead">
- <link rel="stylesheet" type="text/css" href="custom.css"/>
- <script type="text/javascript">
- function hello(){
- alert("Hello");
- }
- </script>
- <link jsf:id="osh" rel="stylesheet" type="text/css" jsf:library="mylib" jsf:name="resource.css"/>
- <script jsf:id="osc" type="text/javascript">
- function hello(){
- alert("Hello");
- }
- </script>
+<head>
+ <title></title>
</head>
-<body jsf:id="idBody">
- <form jsf:id="myForm">
- <a jsf:id="link1" jsf:action="#{test.testAction}"/>
- <a jsf:id="link2" jsf:actionListener="#{test.testActionListener}"/>
- <a jsf:id="link3" jsf:value="/my/new/location.txt"/>
- <a jsf:id="link4" jsf:outcome="rollback"/>
- <button jsf:id="button1" jsf:action="#{test.testAction}"/>
- <button jsf:id="button2" jsf:outcome="rollback"/>
- <img jsf:id="img1" jsf:url="/my/image.png"/>
- <input jsf:id="input1" type="button"/>
- <input jsf:id="input2" type="checkbox"/>
- <input jsf:id="input3" type="color"/>
- <input jsf:id="input4" type="date"/>
- <input jsf:id="input5" type="datetime"/>
- <input jsf:id="input6" type="datetime-local"/>
- <input jsf:id="input7" type="email"/>
- <input jsf:id="input8" type="month"/>
- <input jsf:id="input9" type="number"/>
- <input jsf:id="input10" type="range"/>
- <input jsf:id="input11" type="search"/>
- <input jsf:id="input12" type="time"/>
- <input jsf:id="input13" type="url"/>
- <input jsf:id="input14" type="week"/>
- <input jsf:id="input15" type="file"/>
- <input jsf:id="input16" type="hidden"/>
- <input jsf:id="input17" type="password"/>
- <input jsf:id="input18" type="reset"/>
- <input jsf:id="input19" type="submit"/>
- <input jsf:id="input20" type="anything"/>
- <label jsf:id="label1" />
- <select jsf:id="select1">
- <f:selectItem itemValue="option1"/>
- </select>
- <select jsf:id="select2" multiple="multiple">
- <f:selectItem itemValue="option1"/>
- <f:selectItem itemValue="option2"/>
- </select>
- <textarea jsf:id="textarea1"/>
- </form>
+<body>
+<img src="someimage.gif" alt=""/>
</body>
</html>
\ No newline at end of file