- Add support for HTML5 data-* attributes to the HTML_BASIC renderkit.
This attribute is valid on any h: component. Here is the
specification.
This is for an attribute called "data" which will be on all h: components.
If the view being rendered is not HTML5, the value of this attribute
must be ignored. Otherwise, determine the correct markup element to host
the data- attribute(s). This markup element will always be the
outer-most markup element corresponding precisely to this component
instance. If necessary, a <div> or a <span> must be rendered to host the
data- attribute(s), depending on whether or not the component is,
itself, block or inline in nature.
Interpret the value of the attribute as a JSON string.
If none of the right hand side values in the JSON string is itself a
JSON object, for each name : value pair in the JSON object output
data-[name]="[value]", where name is the name from the name : value
pair, and value is the value from the name : value pair.
If any of the right hand side values in the JSON string is a JSON object
render the attributes according to the following algorithm. Let
nameStack be a stack data structure. Let jsonObj be a JSON object
comprised of jsonName and jsonValue. Parse the value of the attribute as
JSON into jsonObj. Push jsonName onto nameStack. If jsonValue is a JSON
object, recursively apply the algorithm. Otherwise, render a data-
attribute with the name data-stackExplode, where stackExplode is a
printout of the entire stack, starting with the literal string "data-"
and followed by each element in the stack, separated by "-". The value
of such a data- attribute is jsonValue, enclosed in quotes. When all the
values for the current jsonName have been handled, pop jsonName from the
nameStack.
Consider this example.
<h:outputText data="{ a : { b : { c : { d : e, f : g }, h, { i : { j : { k : l } } } } } }" value="foo"/>
This would be rendered as
<span data-a-b-c-d="e" data-a-b-c-f="g" data-a-b-c="h"
data-a-b-c-i-j-k="l">foo</span>
SECTION: Modified Files
----------------------------
M jsf-tools/src/main/java/com/sun/faces/generate/HtmlTaglib21Generator.java
- Fix the component generation so that ivar names don't conflict with
this new attribute.
M jsf-ri/src/main/java/com/sun/faces/renderkit/html_basic/TextRenderer.java
M jsf-ri/src/main/java/com/sun/faces/renderkit/RenderKitUtils.java
M jsf-api/doc/standard-html-renderkit.xml
M jsf-api/doc/core-props.xml
- Implement this in the textrenderer.
- Further work must be done to verify this works for all h: components.
This is tracked in <
http://java.net/jira/browse/JAVASERVERFACES-2418>.
M jsf-ri/mojarra-jsf-impl.bnd
M nbproject/project.xml
M common/ant/dependencies.xml
M common/ant/common.xml
- Introduce dependency on jettison JSON software. This is acceptable
because GlassFish is already using it.
A + test/agnostic/renderKit/basic/src/test/java/com/sun/faces/test/agnostic/renderKit/basic/Issue1089IT.java
A + test/agnostic/renderKit/basic/src/main/webapp/data-attributes.xhtml
- Test in one case, h:outputText.
Sending common/ant/common.xml
Sending common/ant/dependencies.xml
Sending jsf-api/doc/core-props.xml
Sending jsf-api/doc/standard-html-renderkit.xml
Sending jsf-ri/mojarra-jsf-impl.bnd
Sending jsf-ri/src/main/java/com/sun/faces/renderkit/RenderKitUtils.java
Sending jsf-ri/src/main/java/com/sun/faces/renderkit/html_basic/TextRenderer.java
Sending jsf-tools/src/main/java/com/sun/faces/generate/HtmlTaglib21Generator.java
Sending nbproject/project.xml
Adding test/agnostic/renderKit/basic/src/main/webapp/data-attributes.xhtml
Adding test/agnostic/renderKit/basic/src/test/java/com/sun/faces/test/agnostic/renderKit/basic/Issue1089IT.java
Transmitting file data ...........
Committed revision 9947.
--
| edward.burns_at_oracle.com | office: +1 407 458 0017
| homepage: | http://ridingthecrest.com/