1
votes

I want to use the rendered attribute in a ui:fragment to conditionally render a span element in my JSF 2.2 facelet. The JSF 2.2 documentation of ui:fragment lists rendered as an allowed attribute. I am using MyFaces 2.2.12 as JSF implementation, however, and the MyFaces 2.2 documentation of ui:fragment does not list rendered as a valid attribute.

I tried using rendered anyway, and it worked. However, my IDE - IntelliJ - rightly highlights the rendered attribute as an error and tells me it is not allowed in the ui:fragment element.

I saw a response in ui:fragment rendered attribute not working after upgrading Facelets to JSF 2 that there was a documentation bug where rendered falsly wasn't listed in the JSF 2.0 documentation, but the response says nothing about JSF 2.2 or MyFaces 2.2 (presumably because it dates before the release of JSF 2.2).

Is the missing rendered attribute in the MyFaces documentation also just a bug?

With multiple such occurances of the ui:fragment element in a single Facelets file, these "false" errors make finding real errors quite cumbersome. What is the recommended solution for this problem, if it really is just a bug in the documentation?

1
Since I began working with JSF 2 (5 years ago right now) I have faced this situation. The attribute definitelly works, but the IDEs don't consider it (nor Intellij or Eclipse). Seems to be a documentation error that has been ported to 2.1 and 2.2 by the IDE parsers. The attribute is definitelly there in 2.1 docs: stackoverflow.com/questions/3713468/… Don't know in MyFaces.Xtreme Biker
@XtremeBiker thanks for the comment. Ok, then I will just continue to use the rendered attribute. It just concerns me a little that the this documentation bug got fixed in the Mojarra documentation (since version 2.1?), but not in the MyFaces 2.2 documentation.scholt
There's a line in the errata list about this in the JSF 2.2 spec from march 2013. The link is download.oracle.com/otndocs/jcp/jsf-2_2-fr-eval-spec/index.html and it is in the page 406 of the pdf document (C114): Add "rendered" attribute to VDL docs for ui:component and ui:fragment.. So MyFaces seems not to have properly updated this part too.Xtreme Biker

1 Answers

0
votes

rendered is valid attribute in ui:fragment and ui:component in JSF 2.0, 2.1, 2.2. See JSF 2.2 View Declaration Language.

Some IDEs do not propose this attribute in autocomplete (content assistant) mode and validate it as "Unknown attribute". This happens because the rendered attribute was missing in the tag file declaration in JSF 2.0 (even if attribute was presented in the UIComponent) and the IDE validation is based on the tag file declarations. Issue was fixed in JSF 2.1: the missing attribute was added into the tag file declaration. Validation in IDE not always reflect to this change.