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

[jsr372-experts] Re: [JAVASERVERFACES_SPEC_PUBLIC-1270] TagDecorator attributes

From: Edward Burns <edward.burns_at_oracle.com>
Date: Tue, 18 Aug 2015 13:21:00 -0700

>>>>> On Fri, 14 Aug 2015 08:53:35 -0500, manfred riem <manfred.riem_at_oracle.com> said:

MR> Hi all,
MR> I like to bring pass through attributes in line with what the
MR> implementation does here instead of what the current specification says.
MR> See JAVASERVERFACES_SPEC_PUBLIC-1270 for more information.

Spec> Item 2 If the current attribute's namespace is empty or different
Spec> from the argument tag's namespace, let the current attribute be
Spec> convertedTagAttribute. This will have the effect of setting the
Spec> current attribute as an attribute on the attributes map of the
Spec> UIComponent instance represented by this markup.

Spec> Item 3 Otherwise, assume the current attribute's namespace is
Spec> http://xmlns.jcp.org/jsf/passthrough. ConvertedTagAttribute's
Spec> qualified name is the current attribute's local name prefixed by
Spec> "p:". convertedTagAttribute's namespace must be
Spec> http://xmlns.jcp.org/jsf/passthrough.

MK> The third item states, that attributes without a namespace

"namespace is empty" is in item 2.

MK> or with a namespace different from the tag's namespace

"different from the current tag's namespace" is also in item 2.

MK> should be attributes of the component (and NOT pass-through
MK> attributes).

MK> This is not in line with the implementation in Mojarra (which is
MK> correct in my opinion!). Mojarra treats all attributes of a
MK> pass-through element without a namespace as pass-through
MK> attributes. This perfectly makes sense as I would consider
MK> attributes without a prefix in a pass-through element as something
MK> belonging to the HTML tag.

MK> With the behavior defined in the spec, this would not work:

Let's pull this apart and follow the steps in TagDecorator [1]. First,
let's be explicit about the namespaces.

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:jsf="http://xmlns.jcp.org/jsf">

MK> <input type="text" jsf:id="name" jsf:value="#{bean.name}"
MK> placeholder="Enter name"/>


* "Inspect the attributes of the tag argument..." does not apply.

* The default TagDecorator has its decorate() method called, with the
  Tag passed as the argument.

* We don't throw an exception because <input> is in the
  http://www.w3.org/1999/xhtml namespace.

* "input" is treated as the elementName. This leads us to identify
  h:inputText as the "target tag" from the table in the javadoc for
  TagDecorator.

* Now we start to iterate over the attributes in the markup.

  jsf:id="name"

    It's namespace is http://xmlns.jcp.org/jsf, so item 1 applies: make
    it be a component attribute. In this case, call
    component.setId("name").

  type="text"

    It's namespace is not http://xmlns.jcp.org/jsf, so item 1 does not
    apply.

    It's namespace is empty, so item 2 applies. THIS IS THE SPEC BUG.
    It should fall through to item 3.

  jsf:value="#{bean.name}"

    It's namespace is http://xmlns.jcp.org/jsf, so item 1 applies.

  placeHolder="Enter name"

    It's namespace is not http://www.w3.org/1999/xhtml, so item 1 does
    not apply.

    It's namespace is empty so item 2 applies. THIS IS THE SPEC BUG.

Now that we've pinpointed the bug, the question becomes what to do about
it? I suggest we change item 2 to be

  If the current attribute's namespace is non-empty and different from
  the argument tag's namespace, let the current attribute be
  convertedTagAttribute.

Delete the next sentance that starts with "This will have the
effect...".

Ed

-- 
| edward.burns_at_oracle.com | office: +1 407 458 0017
| 55 Business days til JavaOne 2015
| 70 Business days til DOAG 2015
[1] https://javaserverfaces.java.net/docs/2.2/javadocs/javax/faces/view/facelets/TagDecorator.html