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 2014/04/14 18:03:20 UTC
svn commit: r1587237 - in /myfaces/core/trunk/impl/src:
main/java/org/apache/myfaces/view/facelets/component/
main/java/org/apache/myfaces/view/facelets/tag/
main/java/org/apache/myfaces/view/facelets/tag/jsf/html/
test/java/org/apache/myfaces/view/fac...
Author: lu4242
Date: Mon Apr 14 16:03:20 2014
New Revision: 1587237
URL: http://svn.apache.org/r1587237
Log:
MYFACES-3882 Page with template and stylesheet not rendered correctly
Added:
myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/component/_StyleProperties.java
- copied, changed from r1586337, myfaces/core/trunk/api/src/main/java/javax/faces/component/html/_StyleProperties.java
myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/jsf/html/resources/
myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/jsf/html/resources/external.png
- copied unchanged from r1585933, myfaces/site/trunk/src/site/resources/images/external.png
myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/jsf/html/testConvertTagAttributes6.xhtml
- copied, changed from r1586337, myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/jsf/html/testConvertTagAttributes1.xhtml
myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/jsf/html/testConvertTagAttributes7.xhtml
- copied, changed from r1586337, myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/jsf/html/testConvertTagAttributes1.xhtml
Modified:
myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/component/JsfElementRenderer.java
myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/component/_JsfElement.java
myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/MetaRulesetImpl.java
myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/html/DefaultTagDecorator.java
myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/tag/jsf/html/DefaultHtmlDecoratorTestCase.java
myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/jsf/html/testConvertTagAttributes1.xhtml
Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/component/JsfElementRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/component/JsfElementRenderer.java?rev=1587237&r1=1587236&r2=1587237&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/component/JsfElementRenderer.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/component/JsfElementRenderer.java Mon Apr 14 16:03:20 2014
@@ -101,7 +101,7 @@ public class JsfElementRenderer extends
commonPropertiesMarked, commonEventsMarked, component,
component.getClientId(facesContext), behaviors);
}
- CommonPropertyUtils.renderStyleClassProperty(writer, commonPropertiesMarked, component);
+ CommonPropertyUtils.renderStyleProperties(writer, commonPropertiesMarked, component);
HtmlRendererUtils.renderBehaviorizedAttribute(facesContext, writer, HTML.ONLOAD_ATTR, component,
ClientBehaviorEvents.LOAD, behaviors, HTML.ONLOAD_ATTR);
HtmlRendererUtils.renderBehaviorizedAttribute(facesContext, writer, HTML.ONUNLOAD_ATTR, component,
Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/component/_JsfElement.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/component/_JsfElement.java?rev=1587237&r1=1587236&r2=1587237&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/component/_JsfElement.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/component/_JsfElement.java Mon Apr 14 16:03:20 2014
@@ -32,7 +32,7 @@ import org.apache.myfaces.buildtools.mav
defaultEventName = "click",
defaultRendererType="javax.faces.passthrough.Element")
abstract class _JsfElement extends UIPanel implements
- _EventProperties, _FocusBlurProperties, _ChangeSelectProperties
+ _EventProperties, _FocusBlurProperties, _ChangeSelectProperties, _StyleProperties
{
public static final String COMPONENT_FAMILY = "javax.faces.Panel";
public static final String COMPONENT_TYPE = "oam.passthrough.Element";
@@ -50,11 +50,5 @@ abstract class _JsfElement extends UIPan
*/
@JSFProperty(clientEvent="unload")
public abstract String getOnunload();
-
- /**
- * The CSS class for this element. Corresponds to the HTML 'class' attribute.
- *
- */
- @JSFProperty
- public abstract String getStyleClass();
+
}
Copied: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/component/_StyleProperties.java (from r1586337, myfaces/core/trunk/api/src/main/java/javax/faces/component/html/_StyleProperties.java)
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/component/_StyleProperties.java?p2=myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/component/_StyleProperties.java&p1=myfaces/core/trunk/api/src/main/java/javax/faces/component/html/_StyleProperties.java&r1=1586337&r2=1587237&rev=1587237&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/main/java/javax/faces/component/html/_StyleProperties.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/component/_StyleProperties.java Mon Apr 14 16:03:20 2014
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package javax.faces.component.html;
+package org.apache.myfaces.view.facelets.component;
import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFProperty;
Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/MetaRulesetImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/MetaRulesetImpl.java?rev=1587237&r1=1587236&r2=1587237&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/MetaRulesetImpl.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/MetaRulesetImpl.java Mon Apr 14 16:03:20 2014
@@ -30,7 +30,6 @@ import javax.faces.view.facelets.Tag;
import javax.faces.view.facelets.TagAttribute;
import javax.faces.view.facelets.TagException;
import java.beans.IntrospectionException;
-import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -38,7 +37,6 @@ import java.util.Map;
import java.util.WeakHashMap;
import java.util.logging.Level;
import java.util.logging.Logger;
-import javax.faces.render.Renderer;
import org.apache.myfaces.view.facelets.PassthroughRule;
import org.apache.myfaces.view.facelets.tag.jsf.PassThroughLibrary;
@@ -121,12 +119,6 @@ public final class MetaRulesetImpl exten
private final List<MetaRule> _passthroughRules;
- /**
- * Indicates when a tag comes from html markup.
- *
- */
- private final boolean _htmlMarkupTag;
-
public MetaRulesetImpl(Tag tag, Class<?> type)
{
_tag = tag;
@@ -151,7 +143,6 @@ public final class MetaRulesetImpl exten
PassThroughLibrary.NAMESPACE);
TagAttribute[] passthroughAttributeAlias = _tag.getAttributes().getAll(
PassThroughLibrary.ALIAS_NAMESPACE);
- boolean htmlMarkupTag = false;
if (passthroughAttribute.length > 0 ||
passthroughAttributeAlias.length > 0)
@@ -169,10 +160,6 @@ public final class MetaRulesetImpl exten
{
_passthroughAttributes[i] = attribute;
i++;
- if (Renderer.PASSTHROUGH_RENDERER_LOCALNAME_KEY.equals(attribute.getLocalName()))
- {
- htmlMarkupTag = true;
- }
}
else
{
@@ -189,8 +176,6 @@ public final class MetaRulesetImpl exten
_attributes.put(attribute.getLocalName(), attribute);
}
}
-
- _htmlMarkupTag = htmlMarkupTag;
// add default rules
_rules.add(BeanPropertyTagRule.INSTANCE);
@@ -244,96 +229,36 @@ public final class MetaRulesetImpl exten
assert !_rules.isEmpty();
- if (_htmlMarkupTag)
+ if (!_attributes.isEmpty())
{
- // HTML markup component
- if (!_attributes.isEmpty())
+ target = this._getMetadataTarget();
+ int ruleEnd = _rules.size() - 1;
+
+ // now iterate over attributes
+ for (Map.Entry<String, TagAttribute> entry : _attributes.entrySet())
{
- target = this._getMetadataTarget();
- int ruleEnd = _rules.size() - 1;
- int ptRuleEnd = _passthroughRules.size() - 1;
+ Metadata data = null;
- // now iterate over attributes
- for (Map.Entry<String, TagAttribute> entry : _attributes.entrySet())
- {
- Metadata data = null;
+ int i = ruleEnd;
- Method m = target.getWriteMethod(entry.getKey());
+ // First loop is always safe
+ do
+ {
+ MetaRule rule = _rules.get(i);
+ data = rule.applyRule(entry.getKey(), entry.getValue(), target);
+ i--;
+ } while (data == null && i >= 0);
- // if the property is writable
- if (m != null)
- {
- int i = ruleEnd;
-
- // Apply as a normal attribute
- // First loop is always safe
- do
- {
- MetaRule rule = _rules.get(i);
- data = rule.applyRule(entry.getKey(), entry.getValue(), target);
- i--;
- } while (data == null && i >= 0);
- }
- else if (ptRuleEnd >= 0)
- {
- // Apply as passthrough attribute
- int i = ptRuleEnd;
-
- do
- {
- MetaRule rule = _passthroughRules.get(i);
- data = rule.applyRule(entry.getKey(), entry.getValue(), target);
- i--;
- } while (data == null && i >= 0);
- }
-
- if (data == null)
- {
- if (log.isLoggable(Level.SEVERE))
- {
- log.severe(entry.getValue() + " Unhandled by MetaTagHandler for type " + _type.getName());
- }
- }
- else
+ if (data == null)
+ {
+ if (log.isLoggable(Level.SEVERE))
{
- _mappers.add(data);
+ log.severe(entry.getValue() + " Unhandled by MetaTagHandler for type " + _type.getName());
}
}
- }
- }
- else
- {
- if (!_attributes.isEmpty())
- {
- target = this._getMetadataTarget();
- int ruleEnd = _rules.size() - 1;
-
- // now iterate over attributes
- for (Map.Entry<String, TagAttribute> entry : _attributes.entrySet())
+ else
{
- Metadata data = null;
-
- int i = ruleEnd;
-
- // First loop is always safe
- do
- {
- MetaRule rule = _rules.get(i);
- data = rule.applyRule(entry.getKey(), entry.getValue(), target);
- i--;
- } while (data == null && i >= 0);
-
- if (data == null)
- {
- if (log.isLoggable(Level.SEVERE))
- {
- log.severe(entry.getValue() + " Unhandled by MetaTagHandler for type " + _type.getName());
- }
- }
- else
- {
- _mappers.add(data);
- }
+ _mappers.add(data);
}
}
}
@@ -377,7 +302,7 @@ public final class MetaRulesetImpl exten
}
}
}
-
+
if (_mappers.isEmpty())
{
return NONE;
Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/html/DefaultTagDecorator.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/html/DefaultTagDecorator.java?rev=1587237&r1=1587236&r2=1587237&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/html/DefaultTagDecorator.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/html/DefaultTagDecorator.java Mon Apr 14 16:03:20 2014
@@ -184,15 +184,7 @@ public class DefaultTagDecorator impleme
public Tag decorate(Tag tag)
{
boolean jsfNamespaceFound = false;
- // The tag is <jsf:element ...> is an special case because all empty attributes should be copied
- // as passthrough attributes, like it was a markup attribute.
- if (JSF_NAMESPACE.equals(tag.getNamespace()) || JSF_ALIAS_NAMESPACE.equals(tag.getNamespace()))
- {
- if ("element".equals(tag.getLocalName()))
- {
- return NO_MATCH_SELECTOR.decorate(tag, convertTagAttributes(tag));
- }
- }
+
for (String namespace : tag.getAttributes().getNamespaces())
{
if (JSF_NAMESPACE.equals(namespace) || JSF_ALIAS_NAMESPACE.equals(namespace))
@@ -260,57 +252,17 @@ public class DefaultTagDecorator impleme
}
private TagAttributes convertTagAttributes(Tag tag)
- {
+ {
TagAttribute[] sourceTagAttributes = tag.getAttributes().getAll();
String elementNameTagLocalName = tag.getLocalName();
- if ("element".equals(tag.getLocalName()) &&
- JSF_NAMESPACE.equals(tag.getNamespace()) || JSF_ALIAS_NAMESPACE.equals(tag.getNamespace()))
- {
- // In jsf:element tag, the attribute elementName is required, so from this point we can
- // assume that elementName has been set. But we need to enable the special treatement
- // for attribute in jsf:element, so the way to do it is
- TagAttribute elemNameAttr = tag.getAttributes().get(Renderer.PASSTHROUGH_RENDERER_LOCALNAME_KEY);
- if (elemNameAttr != null)
- {
- elementNameTagLocalName = elemNameAttr.getValue();
- }
- }
+
TagAttribute elementNameTagAttribute = new TagAttributeImpl(
tag.getLocation(), PASS_THROUGH_NAMESPACE , Renderer.PASSTHROUGH_RENDERER_LOCALNAME_KEY,
P_ELEMENTNAME, elementNameTagLocalName );
- // FIXME: Doing a black box test over Mojarra it was found that passthrough
- // attributes are added to both passthrough map and normal attribute map. It seems
- // in some point the attributes are copied, but the spec doesn't mention where this
- // should be. The relevant case happens when the attribute has no associated namespace,
- // because in that case the user suppose the attribute will be passed through. If the use
- // jsf or passthrough namespace it is clear where it should go.
-
// 1. Count how many attributes requires to be duplicated
int duplicateCount = 0;
- /*
- for (int i = 0; i < sourceTagAttributes.length; i++)
- {
- TagAttribute tagAttribute = sourceTagAttributes[i];
- String namespace = tagAttribute.getNamespace();
- if (namespace == null)
- {
- // should not happen, but let it because org.xml.sax.Attributes considers it
- duplicateCount++;
- }
- else if (tagAttribute.getNamespace().length() == 0)
- {
- // "... If the current attribute's namespace is empty
- // let the current attribute be convertedTagAttribute. ..."
- duplicateCount++;
- }
- else if (!isReservedJSFAttribute(tagAttribute.getLocalName()) &&
- (JSF_NAMESPACE.equals(namespace) || JSF_ALIAS_NAMESPACE.equals(namespace)))
- {
- duplicateCount++;
- }
- }*/
TagAttribute[] convertedTagAttributes = new TagAttribute[
sourceTagAttributes.length+1+duplicateCount];
@@ -323,6 +275,39 @@ public class DefaultTagDecorator impleme
String convertedNamespace;
String qname;
String namespace = tagAttribute.getNamespace();
+
+ /*
+ -= Leonardo Uribe =- After check the javadoc and compare it with the code and try some
+ examples with the implementation done in the RI, we found that the javadoc of
+ TagDecorator has some bugs. Below is the description of the implementation done, which
+ resembles the behavior found on the RI.
+
+ "...
+ For each of argument tag's attributes obtain a reference to a TagAttribute
+ with the following characteristics. For discussion let such an attribute be
+ convertedTagAttribute.
+
+ * convertedTagAttribute's location: from the argument tag's location.
+
+ * If the current attribute's namespace is http://xmlns.jcp.org/jsf,
+ convertedTagAttribute's qualified name must be the current attribute's
+ local name and convertedTagAttribute's namespace must be the empty string.
+ This will have the effect of setting the current attribute as a proper
+ property on the UIComponent instance represented by this markup.
+
+ * If the current attribute's namespace is empty, assume the current
+ attribute's namespace is http://xmlns.jcp.org/jsf/passthrough.
+ ConvertedTagAttribute's qualified name is the current attribute's
+ local name prefixed by "p:". convertedTagAttribute's namespace must be
+ http://xmlns.jcp.org/jsf/passthrough.
+
+ * Otherwise, if the current attribute's namespace is not empty, let
+ the current attribute be convertedTagAttribute. This will have the
+ effect of let the attribute be processed by the meta rules defined
+ by the TagHandler instance associated with the generated target
+ component.
+ ..."
+ */
if (JSF_NAMESPACE.equals(namespace) || JSF_ALIAS_NAMESPACE.equals(namespace))
{
// "... If the current attribute's namespace is http://xmlns.jcp.org/jsf, convertedTagAttribute's
@@ -334,26 +319,6 @@ public class DefaultTagDecorator impleme
convertedTagAttributes[j] = new TagAttributeImpl(tagAttribute.getLocation(),
convertedNamespace, tagAttribute.getLocalName(), qname, tagAttribute.getValue());
-
- /*
- if (!isReservedJSFAttribute(qname))
- {
- j++;
- // Duplicate passthrough
- // -= Leonardo Uribe =- After discussion with Ed Burns and Frank Caputo, the reason is jsf
- // namespace in an attribute is used to convert the tag into jsf:element, so there are cases
- // where you want the attribute to be passed into the passthrough attribute map instead the
- // normal attribute map. It is not expected to override jsf:element because this is a
- // special component used to output markup, so it has been defined the attribute names that
- // does not require this duplication. It was also found that for the remaining cases, copy
- // the passthrough attribute does not have any effect, because by effect of the renderer
- // associated to the component these attribute are passed through by the renderer code and
- // time later when the passthrough attributes are rendered, there is a check that indicates
- // that the attribute has been already rendered.
- convertedTagAttributes[j] = new TagAttributeImpl(tagAttribute.getLocation(),
- PASS_THROUGH_NAMESPACE, tagAttribute.getLocalName(),
- "p:"+tagAttribute.getLocalName(), tagAttribute.getValue());
- }*/
}
else if (namespace == null)
{
@@ -361,13 +326,13 @@ public class DefaultTagDecorator impleme
// -= Leonardo Uribe =- after conversation with Frank Caputo, who was the main contributor for
// this feature in JSF 2.2, he said that if the namespace is empty the intention is pass the
// attribute to the passthrough attribute map, so there is an error in the spec documentation.
- convertedTagAttributes[j] = tagAttribute;
- /*
- j++;
- // Duplicate passthrough
+ //convertedTagAttributes[j] = tagAttribute;
+
+ convertedNamespace = PASS_THROUGH_NAMESPACE;
+ qname = "p:"+tagAttribute.getLocalName();
+
convertedTagAttributes[j] = new TagAttributeImpl(tagAttribute.getLocation(),
- PASS_THROUGH_NAMESPACE, tagAttribute.getLocalName(),
- "p:"+tagAttribute.getLocalName(), tagAttribute.getValue());*/
+ convertedNamespace, tagAttribute.getLocalName(), qname, tagAttribute.getValue());
}
else if (tagAttribute.getNamespace().length() == 0)
{
@@ -376,31 +341,20 @@ public class DefaultTagDecorator impleme
// -= Leonardo Uribe =- after conversation with Frank Caputo, who was the main contributor for
// this feature in JSF 2.2, he said that if the namespace is empty the intention is pass the
// attribute to the passthrough attribute map, so there is an error in the spec documentation.
- convertedTagAttributes[j] = tagAttribute;
- /*
- j++;
- // Duplicate passthrough
+ //convertedTagAttributes[j] = tagAttribute;
+
+ convertedNamespace = PASS_THROUGH_NAMESPACE;
+ qname = "p:"+tagAttribute.getLocalName();
+
convertedTagAttributes[j] = new TagAttributeImpl(tagAttribute.getLocation(),
- PASS_THROUGH_NAMESPACE, tagAttribute.getLocalName(),
- "p:"+tagAttribute.getLocalName(), tagAttribute.getValue());*/
+ convertedNamespace, tagAttribute.getLocalName(), qname, tagAttribute.getValue());
}
- else if (!tag.getNamespace().equals(tagAttribute.getNamespace()))
+ else /*if (!tag.getNamespace().equals(tagAttribute.getNamespace()))*/
{
// "... or different from the argument tag's namespace,
// let the current attribute be convertedTagAttribute. ..."
convertedTagAttributes[j] = tagAttribute;
}
- else
- {
- // "... Otherwise, assume the current attribute's namespace is http://xmlns.jcp.org/jsf/passthrough.
- // ConvertedTagAttribute's qualified name is the current attribute's local name prefixed by
- // p:". convertedTagAttribute's namespace must be http://xmlns.jcp.org/jsf/passthrough.
- convertedNamespace = PASS_THROUGH_NAMESPACE;
- qname = "p:"+tagAttribute.getLocalName();
-
- convertedTagAttributes[j] = new TagAttributeImpl(tagAttribute.getLocation(),
- convertedNamespace, tagAttribute.getLocalName(), qname, tagAttribute.getValue());
- }
if (Renderer.PASSTHROUGH_RENDERER_LOCALNAME_KEY.equals(convertedTagAttributes[j].getLocalName()) && (
PASS_THROUGH_NAMESPACE.equals(convertedTagAttributes[j].getNamespace()) ||
Modified: myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/tag/jsf/html/DefaultHtmlDecoratorTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/tag/jsf/html/DefaultHtmlDecoratorTestCase.java?rev=1587237&r1=1587236&r2=1587237&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/tag/jsf/html/DefaultHtmlDecoratorTestCase.java (original)
+++ myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/tag/jsf/html/DefaultHtmlDecoratorTestCase.java Mon Apr 14 16:03:20 2014
@@ -345,15 +345,13 @@ public class DefaultHtmlDecoratorTestCas
Assert.assertNotNull(input1);
Assert.assertEquals(input1.getPassThroughAttributes().get("placeholder"), "Enter text");
- //Assert.assertEquals(input1.getAttributes().get("placeholder"), "Enter text");
Assert.assertNull(input1.getAttributes().get("placeholder"));
- //Assert.assertEquals(input1.getAttributes().get("customAttr"), "SomeValue");
- Assert.assertNull(input1.getAttributes().get("customAttr"));
+ Assert.assertEquals(input1.getAttributes().get("customAttr"), "SomeValue");
// Attributes outside "id", "binding", "rendered" or "transient" can be
// copied on passthrough attribute map.
- Assert.assertEquals(input1.getPassThroughAttributes().get("customAttr"), "SomeValue");
+ Assert.assertNull(input1.getPassThroughAttributes().get("customAttr"));
Assert.assertEquals(input1.getPassThroughAttributes().get("data_up"), "Going Up");
Assert.assertNull(input1.getAttributes().get("data_up"));
@@ -377,21 +375,22 @@ public class DefaultHtmlDecoratorTestCas
//Assert.assertEquals(input2.getAttributes().get("placeholder"), "Enter text");
Assert.assertNull(input2.getAttributes().get("placeholder"));
- //Assert.assertEquals(input2.getAttributes().get("customAttr"), "SomeValue");
- Assert.assertNull(input2.getAttributes().get("customAttr"));
- Assert.assertEquals(input2.getPassThroughAttributes().get("customAttr"), "SomeValue");
+ Assert.assertEquals(input2.getAttributes().get("customAttr"), "SomeValue");
+ //Assert.assertNull(input2.getAttributes().get("customAttr"));
+ //Assert.assertEquals(input2.getPassThroughAttributes().get("customAttr"), "SomeValue");
+ Assert.assertNull(input2.getPassThroughAttributes().get("customAttr"));
Assert.assertEquals(input2.getPassThroughAttributes().get("data_up"), "Going Up");
Assert.assertNull(input2.getAttributes().get("data_up"));
// note there is no type attribute, so it is translated into a jsf:element, and in that
// component, "value" is not defined, so it is set as passthrough
- Assert.assertNull(input2.getValueExpression("value"));
- Assert.assertNotNull(input2.getPassThroughAttributes().get("value"));
- Assert.assertNull(input2.getAttributes().get("value"));
+ Assert.assertNotNull(input2.getValueExpression("value"));
+ Assert.assertNull(input2.getPassThroughAttributes().get("value"));
+ Assert.assertNotNull(input2.getAttributes().get("value"));
//<jsf:element id="box3" elementName="meter"
- // value="#{test.value}" jsf:customAttr="SomeValue"
+ // value="#{test.value}" customAttr="SomeValue"
// onclick="alert('hello')"
// placeholder="Enter text"
// pt:data_up="Going Up">
@@ -400,19 +399,19 @@ public class DefaultHtmlDecoratorTestCas
UIComponent input3 = root.findComponent("myForm:box3");
Assert.assertFalse(input3 instanceof UIInput);
Assert.assertEquals(input3.getRendererType(), "javax.faces.passthrough.Element");
+
+ Assert.assertEquals(input3.getAttributes().get("placeholder"), "Enter text");
+ Assert.assertNull(input3.getPassThroughAttributes().get("placeholder"));
- Assert.assertEquals(input3.getPassThroughAttributes().get("placeholder"), "Enter text");
- Assert.assertNull(input3.getAttributes().get("placeholder"));
-
- Assert.assertNull(input3.getAttributes().get("customAttr"));
- Assert.assertEquals(input3.getPassThroughAttributes().get("customAttr"), "SomeValue");
+ Assert.assertNull(input3.getPassThroughAttributes().get("customAttr"));
+ Assert.assertEquals(input3.getAttributes().get("customAttr"), "SomeValue");
Assert.assertEquals(input3.getPassThroughAttributes().get("data_up"), "Going Up");
Assert.assertNull(input3.getAttributes().get("data_up"));
- Assert.assertNull(input3.getValueExpression("value"));
- Assert.assertNotNull(input3.getPassThroughAttributes().get("value"));
- Assert.assertNull(input3.getAttributes().get("value"));
+ Assert.assertNotNull(input3.getValueExpression("value"));
+ Assert.assertNull(input3.getPassThroughAttributes().get("value"));
+ Assert.assertNotNull(input3.getAttributes().get("value"));
//Assert.assertEquals(input2.getPassThroughAttributes().get("elementName"), "meter");
@@ -438,12 +437,9 @@ public class DefaultHtmlDecoratorTestCas
Assert.assertNotNull(box5);
UIComponent boxDiv5 = box5.getChildren().get(0);
Assert.assertNotNull(boxDiv5);
- Assert.assertNull(boxDiv5.getAttributes().get("style"));
- Assert.assertEquals(boxDiv5.getPassThroughAttributes().get("style"), "noprint");
-
- UIComponent box6 = root.findComponent("myForm:box6");
- Assert.assertNotNull(box6);
- Assert.assertEquals(box6.getAttributes().get("onclick"), "alert('hello')");
+ Assert.assertNotNull(boxDiv5.getAttributes().get("style"));
+ //Assert.assertEquals(boxDiv5.getPassThroughAttributes().get("style"), "noprint");
+ Assert.assertNull(boxDiv5.getPassThroughAttributes().get("style"));
StringWriter sw = new StringWriter();
@@ -454,7 +450,7 @@ public class DefaultHtmlDecoratorTestCas
new HtmlRenderedAttr("data_up", "Going Up"),
new HtmlRenderedAttr("placeholder", "Enter text"),
new HtmlRenderedAttr("onclick", "alert('hello')"),
- new HtmlRenderedAttr("customAttr", "SomeValue"),
+ //new HtmlRenderedAttr("customAttr", "SomeValue"),
new HtmlRenderedAttr("value", "value1")
};
@@ -479,7 +475,7 @@ public class DefaultHtmlDecoratorTestCas
attrs = new HtmlRenderedAttr[]{
new HtmlRenderedAttr("data_up", "Going Up"),
new HtmlRenderedAttr("onclick", "alert('hello')"),
- new HtmlRenderedAttr("customAttr", "SomeValue"),
+ //new HtmlRenderedAttr("customAttr", "SomeValue"),
new HtmlRenderedAttr("placeholder", "Enter text")
};
@@ -501,9 +497,9 @@ public class DefaultHtmlDecoratorTestCas
attrs = new HtmlRenderedAttr[]{
new HtmlRenderedAttr("data_up", "Going Up"),
- new HtmlRenderedAttr("placeholder", "Enter text"),
- new HtmlRenderedAttr("customAttr", "SomeValue"),
- new HtmlRenderedAttr("value", "value1"),
+ //new HtmlRenderedAttr("placeholder", "Enter text"),
+ //new HtmlRenderedAttr("customAttr", "SomeValue"),
+ //new HtmlRenderedAttr("value", "value1"),
new HtmlRenderedAttr("onclick", "alert('hello')"),
};
@@ -558,38 +554,39 @@ public class DefaultHtmlDecoratorTestCas
Assert.assertTrue(sw.toString().contains("MYBOX5"));
Assert.assertTrue(sw.toString().contains("<div "));
Assert.assertTrue(sw.toString().contains("</div>"));
+ }
+
+ @Test
+ public void testConvertTagAttributes6() throws Exception
+ {
+ request.getSession().setAttribute("test", new MockBean());
- // TEST 6
-
- sw = new StringWriter();
- mrw = new HtmlResponseWriterImpl(sw, "text/html", "UTF-8");
- facesContext.setResponseWriter(mrw);
-
- box6.encodeAll(facesContext);
+ UIViewRoot root = facesContext.getViewRoot();
+ vdl.buildView(facesContext, root, "testConvertTagAttributes6.xhtml");
- sw.flush();
-
- //<div jsf:id="box6" onclick="alert('hello')">
+ //<div jsf:id="box6" jsf:onclick="alert('hello')">
// <f:ajax event="click" render="box5"/>
// MYBOX6
//</div>
// Try second time, to avoid the script section by f:ajax effect
- sw = new StringWriter();
- mrw = new HtmlResponseWriterImpl(sw, "text/html", "UTF-8");
+ UIComponent box6 = root.findComponent("myForm:box6");
+ Assert.assertNotNull(box6);
+ Assert.assertEquals(box6.getAttributes().get("onclick"), "alert('hello')");
+
+ StringWriter sw = new StringWriter();
+ ResponseWriter mrw = new HtmlResponseWriterImpl(sw, "text/html", "UTF-8");
facesContext.setResponseWriter(mrw);
-
+
box6.encodeAll(facesContext);
sw.flush();
- attrs = new HtmlRenderedAttr[]{
+ HtmlRenderedAttr[] attrs = new HtmlRenderedAttr[]{
new HtmlRenderedAttr("onclick",
"jsf.util.chain(document.getElementById('myForm:box6'), event,'alert(\\'hello\\')', "
+ "'jsf.ajax.request(\\'myForm:box6\\',event,{render:\\'myForm:box5 \\',"
+ "\\'javax.faces.behavior.event\\':\\'click\\'})');"),
};
-
-
HtmlCheckAttributesUtil.checkRenderedAttributes(attrs, sw.toString());
if(HtmlCheckAttributesUtil.hasFailedAttrRender(attrs))
{
@@ -599,4 +596,42 @@ public class DefaultHtmlDecoratorTestCas
Assert.assertTrue(sw.toString().contains("<div "));
Assert.assertTrue(sw.toString().contains("</div>"));
}
+
+ @Test
+ public void testConvertTagAttributes7() throws Exception
+ {
+ request.getSession().setAttribute("test", new MockBean());
+
+ UIViewRoot root = facesContext.getViewRoot();
+ vdl.buildView(facesContext, root, "testConvertTagAttributes7.xhtml");
+
+ //<h:panelGroup id="box7">
+ // <img jsf:name="external.png" alt="Some Logo"/>
+ //</h:panelGroup>
+
+ UIComponent box7 = root.findComponent("myForm:box7");
+ Assert.assertNotNull(box7);
+ UIComponent boxDiv7 = box7.getChildren().get(0);
+ Assert.assertNotNull(boxDiv7);
+
+ StringWriter sw = new StringWriter();
+
+ ResponseWriter mrw = new HtmlResponseWriterImpl(sw, "text/html", "UTF-8");
+ facesContext.setResponseWriter(mrw);
+
+ boxDiv7.encodeAll(facesContext);
+
+ sw.flush();
+ HtmlRenderedAttr[] attrs = new HtmlRenderedAttr[]{
+ new HtmlRenderedAttr("alt", "Some Logo"),
+ };
+
+ HtmlCheckAttributesUtil.checkRenderedAttributes(attrs, sw.toString());
+ if(HtmlCheckAttributesUtil.hasFailedAttrRender(attrs))
+ {
+ Assert.fail(HtmlCheckAttributesUtil.constructErrorMessage(attrs, sw.toString()));
+ }
+ Assert.assertTrue(sw.toString().contains("<img "));
+ Assert.assertTrue(sw.toString().contains("javax.faces.resource/external.png"));
+ }
}
Modified: myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/jsf/html/testConvertTagAttributes1.xhtml
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/jsf/html/testConvertTagAttributes1.xhtml?rev=1587237&r1=1587236&r2=1587237&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/jsf/html/testConvertTagAttributes1.xhtml (original)
+++ myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/jsf/html/testConvertTagAttributes1.xhtml Mon Apr 14 16:03:20 2014
@@ -36,7 +36,7 @@
pt:data_up="Going Up">Hello World!</input>
<jsf:element id="box3" elementName="meter"
- value="#{test.value}" jsf:customAttr="SomeValue"
+ value="#{test.value}" customAttr="SomeValue"
onclick="alert('hello')"
placeholder="Enter text"
pt:data_up="Going Up">
@@ -55,10 +55,15 @@
</div>
</h:panelGroup>
- <div jsf:id="box6" onclick="alert('hello')">
+ <div jsf:id="box6" jsf:onclick="alert('hello')">
<f:ajax event="click" render="box5"/>
MYBOX6
</div>
+
+ <h:panelGroup id="box7">
+ <img jsf:name="external.png" alt="Some Logo"/>
+ </h:panelGroup>
+
</form>
</body>
</html>
\ No newline at end of file
Copied: myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/jsf/html/testConvertTagAttributes6.xhtml (from r1586337, myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/jsf/html/testConvertTagAttributes1.xhtml)
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/jsf/html/testConvertTagAttributes6.xhtml?p2=myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/jsf/html/testConvertTagAttributes6.xhtml&p1=myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/jsf/html/testConvertTagAttributes1.xhtml&r1=1586337&r2=1587237&rev=1587237&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/jsf/html/testConvertTagAttributes1.xhtml (original)
+++ myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/jsf/html/testConvertTagAttributes6.xhtml Mon Apr 14 16:03:20 2014
@@ -23,42 +23,18 @@
</head>
<body>
<form jsf:id="myForm">
- <input jsf:id="box1" type="text"
- jsf:value="#{test.value}" jsf:customAttr="SomeValue"
- onclick="alert('hello')"
- placeholder="Enter text"
- pt:data_up="Going Up"/>
-
- <input jsf:id="box2" pt:elementName="meter"
- jsf:value="#{test.value}" jsf:customAttr="SomeValue"
- onclick="alert('hello')"
- placeholder="Enter text"
- pt:data_up="Going Up">Hello World!</input>
-
- <jsf:element id="box3" elementName="meter"
- value="#{test.value}" jsf:customAttr="SomeValue"
- onclick="alert('hello')"
- placeholder="Enter text"
- pt:data_up="Going Up">
- Hello Element!
- </jsf:element>
-
- <h:panelGroup id="box4">
- <div jsf:class="noprint">
- MYBOX4
- </div>
- </h:panelGroup>
-
+
<h:panelGroup id="box5">
<div jsf:style="noprint">
MYBOX5
</div>
- </h:panelGroup>
+ </h:panelGroup>
- <div jsf:id="box6" onclick="alert('hello')">
+ <div jsf:id="box6" jsf:onclick="alert('hello')">
<f:ajax event="click" render="box5"/>
MYBOX6
</div>
+
</form>
</body>
</html>
\ No newline at end of file
Copied: myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/jsf/html/testConvertTagAttributes7.xhtml (from r1586337, myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/jsf/html/testConvertTagAttributes1.xhtml)
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/jsf/html/testConvertTagAttributes7.xhtml?p2=myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/jsf/html/testConvertTagAttributes7.xhtml&p1=myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/jsf/html/testConvertTagAttributes1.xhtml&r1=1586337&r2=1587237&rev=1587237&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/jsf/html/testConvertTagAttributes1.xhtml (original)
+++ myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/jsf/html/testConvertTagAttributes7.xhtml Mon Apr 14 16:03:20 2014
@@ -23,42 +23,11 @@
</head>
<body>
<form jsf:id="myForm">
- <input jsf:id="box1" type="text"
- jsf:value="#{test.value}" jsf:customAttr="SomeValue"
- onclick="alert('hello')"
- placeholder="Enter text"
- pt:data_up="Going Up"/>
-
- <input jsf:id="box2" pt:elementName="meter"
- jsf:value="#{test.value}" jsf:customAttr="SomeValue"
- onclick="alert('hello')"
- placeholder="Enter text"
- pt:data_up="Going Up">Hello World!</input>
-
- <jsf:element id="box3" elementName="meter"
- value="#{test.value}" jsf:customAttr="SomeValue"
- onclick="alert('hello')"
- placeholder="Enter text"
- pt:data_up="Going Up">
- Hello Element!
- </jsf:element>
-
- <h:panelGroup id="box4">
- <div jsf:class="noprint">
- MYBOX4
- </div>
- </h:panelGroup>
-
- <h:panelGroup id="box5">
- <div jsf:style="noprint">
- MYBOX5
- </div>
+
+ <h:panelGroup id="box7">
+ <img jsf:name="external.png" alt="Some Logo"/>
</h:panelGroup>
- <div jsf:id="box6" onclick="alert('hello')">
- <f:ajax event="click" render="box5"/>
- MYBOX6
- </div>
</form>
</body>
</html>
\ No newline at end of file