Hi,
+1, it would be easier to read and understand. But I think there is
also problem with this approach :
- it's quite verbose
- there is no possibility to nest data-* attributes
- it's not really dynamic. If you need to have conditionnal data-*
attributes, you would need to have a "rendered" attribute in the
<f:attribute> tag, and test your condition for each tag. A bit
overkill. Easier to build your JSON string in a Java method and pass it
to the "data" attribute.
- how would you explain that there is some attributes in the tag itself
and other that need to use <f:attribute> ? Why not having all of them
either on the tag itself or using <f:attribute> ?
So I'm fine with having the <f:attribute> (or <f:dataAttribute>), it's
easy to use it for simple case. But I would also provide the "data"
attribute supporting JSON for real world applications having complex
data-* attributes cooperating with their Javascript.
About other topics, I agree the "data-*" attributes should always be
generated, even without a HTML5 doctype because it can be use by
Javascript more generally (see the Twitter Bootstrap project).
I also think that EL should be supported inside the JSON. The following
code should be ok :
<h:outputText value="Test" data="{toggle: #{bean.dataToggle}, hide:
#{bean.hide}}" />
I was talking with RichFaces guys about "data-*" attributes. Here is a
summary of our discussion :
https://issues.jboss.org/browse/RF-12177
Regards,