jsr344-experts@javaserverfaces-spec-public.java.net

[jsr344-experts] Re: [1089-HTML5-data-*attributes] PROPOSAL

From: Edward Burns <edward.burns_at_oracle.com>
Date: Thu, 17 May 2012 07:48:28 -0700

>>>>> On Wed, 16 May 2012 19:22:29 +0200, Martin Marinschek <mmarinschek_at_apache.org> said:

MM> +1 for Andy's comments!

I have modified the spec and impl to conform to Andy's suggestions.

Here is the commit log, which contains the pertinent excerpts.

- Rework specification and implementation of data-* attributes per EG suggestions.

- Dump JSON in favor of new <f:dataAttribute> element.

  Add an HTML5 data-* attribute to the enclosing component.

  Lazily create a java.util.Map store it in the component attributes map
  under the under the keygiven by the value of the symbolic constant
  UIComponent.DATA_ATTRIBUTES_KEY. Add an entryin the map
  with the name and value taken from the corresponding attributes on
  this element, preserving the ValueExpression nature of
  the name and value, if necessary.

  name

  The name of the data-* attribute. The value of name will be appended
  to the literal string "data-" (without the quotes) in the rendered
  markup for the component, as specified in the overview for the
  HTML_BASIC RenderKit.

  value

- Specify how to handle this map. Add this text to the overview of the
  HTML_BASIC RenderKit.

General notes regarding HTML5 support.

The HTML_BASIC RenderKit supports HTML 5 where it makes sense to do so.

    Support for data-* attributes

    If the component to be encoded has an entry in its component
    attributes map under the key given by the value of the symbolic
    constant UIComponent.DATA_ATTRIBUTES_KEY, this entry must be a
    Map<Object, Object>. If an entry is present under that key, but its
    type is not as expected, a FacesException must be thrown. Otherwise,
    determine the correct markup element to host the data-
    attribute(s). Let this element be dataHostingElement. 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. For each entry in the map, do the following.

    If the key is a ValueExpression get its value and append it to the
    literal string "data-", without the quotes. Otherwise get the string
    value of the key and append it to the literal string "data-" without
    the quotes. Let the result be dataAttributeName.

    If the value is a ValueExpression get its value. Otherwise get the
    string value of the entry's value. Let the result be
    dataAttributeValue.

    Render an attribute on dataHostingElement using
    ResponseWriter.writeAttribute(). The name of the attribute is
    dataAttributeName and the value of the attribute is
    dataAttributeValue. Also pass dataAttributeName as the last argument
    to ResponseWriter.writeAttribute().

SECTION: Modified Files
----------------------------
M jsf-api/doc/standard-html-renderkit-base.xml
M jsf-api/doc/standard-html-renderkit.xml

- Spec language.

M jsf-api/src/main/java/javax/faces/component/UIComponent.java

- Add DATA_ATTRIBUTES_KEY

  The value of this constant is used as the key in the component
  attributes Map for the Map<Object,Object> that renderers must use to
  render the HTML 5 data-* attributes.

A + jsf-ri/src/main/java/com/sun/faces/facelets/tag/jsf/core/DataAttributeHandler.java
M jsf-ri/src/main/java/com/sun/faces/facelets/tag/jsf/core/CoreLibrary.java

- Populate the DATA_ATTRIBUTES data structure.

M jsf-ri/src/main/java/com/sun/faces/renderkit/html_basic/TextRenderer.java

- Render the DATA_ATTRIBUTES data structure

M jsf-tools/src/main/java/com/sun/faces/generate/HtmlTaglib21Generator.java
M jsf-ri/mojarra-jsf-impl.bnd
M nbproject/project.xml
M common/ant/dependencies.xml
M common/ant/common.xml
M jsf-api/doc/core-props.xml

- Roll back previous approach

M jsf-ri/conf/share/facelets_jsf_core.tld

- Specify how to populate the DATA_ATTRIBUTES data structure.

M jsf-tools/src/main/resources/com/sun/faces/generate/facesdoc/renderkit-summary.top

- Fix stylesheet link.

M jsf-ri/conf/share/tlddoc-resources/stylesheet.css

- Attribute f:dataAttribute to this version

M jsf-ri/src/main/java/com/sun/faces/renderkit/RenderKitUtils.java
M jsf-ri/src/main/java/com/sun/faces/util/Util.java

- Rework approach

M test/agnostic/renderKit/basic/src/test/java/com/sun/faces/test/agnostic/renderKit/basic/Issue1089IT.java
M test/agnostic/renderKit/basic/src/main/webapp/data-attributes.xhtml

- New test content.
Sending common/ant/common.xml
Sending common/ant/dependencies.xml
Sending jsf-api/doc/core-props.xml
Sending jsf-api/doc/standard-html-renderkit-base.xml
Sending jsf-api/doc/standard-html-renderkit.xml
Sending jsf-api/src/main/java/javax/faces/component/UIComponent.java
Sending jsf-ri/conf/share/facelets_jsf_core.tld
Sending jsf-ri/conf/share/tlddoc-resources/stylesheet.css
Sending jsf-ri/mojarra-jsf-impl.bnd
Sending jsf-ri/src/main/java/com/sun/faces/facelets/tag/jsf/core/CoreLibrary.java
Adding jsf-ri/src/main/java/com/sun/faces/facelets/tag/jsf/core/DataAttributeHandler.java
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-ri/src/main/java/com/sun/faces/util/Util.java
Sending jsf-tools/src/main/java/com/sun/faces/generate/HtmlTaglib21Generator.java
Sending jsf-tools/src/main/resources/com/sun/faces/generate/facesdoc/renderkit-summary.top
Sending nbproject/project.xml
Sending test/agnostic/renderKit/basic/src/main/webapp/data-attributes.xhtml
Sending test/agnostic/renderKit/basic/src/test/java/com/sun/faces/test/agnostic/renderKit/basic/Issue1089IT.java
Transmitting file data ...................
Committed revision 9960.

-- 
| edward.burns_at_oracle.com | office: +1 407 458 0017
| homepage:               | http://ridingthecrest.com/