简体   繁体   English

“ ui:fragment”中的“ rendered”属性

[英]“rendered” attribute in “ui:fragment”

I want to use the rendered attribute in a ui:fragment to conditionally render a span element in my JSF 2.2 facelet. 我想在ui:fragment使用rendered属性在JSF 2.2 facelet中有条件地渲染span元素。 The JSF 2.2 documentation of ui:fragment lists rendered as an allowed attribute. ui:fragment列表的JSF 2.2文档 rendered为允许的属性。 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. 我使用MyFaces 2.2.12作为JSF实现,但是ui:fragmentMyFaces 2.2文档 列出rendered为有效属性的列表。

I tried using rendered anyway, and it worked. 无论如何我都尝试使用rendered ,并且可以正常工作。 However, my IDE - IntelliJ - rightly highlights the rendered attribute as an error and tells me it is not allowed in the ui:fragment element. 但是,我的IDE-IntelliJ-正确地将rendered属性突出rendered为错误,并告诉我ui:fragment元素中不允许这样做。

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). 在将Facelets升级到JSF 2后 ,我看到ui:fragment render属性的响应不起作用,因为存在一个文档错误,在JSF 2.0文档中未列出rendered错误,但是该响应没有说明JSF 2.2或MyFaces 2.2(大概是因为它的日期早于JSF 2.2的发布)。

Is the missing rendered attribute in the MyFaces documentation also just a bug? MyFaces文档中缺少的rendered属性是否也只是一个错误?

With multiple such occurances of the ui:fragment element in a single Facelets file, these "false" errors make finding real errors quite cumbersome. 在单个Facelets文件中多次发生ui:fragment元素时,这些“假”错误使查找实际错误变得非常麻烦。 What is the recommended solution for this problem, if it really is just a bug in the documentation? 如果确实只是文档中的错误,那么建议的解决方案是什么?

rendered is valid attribute in ui:fragment and ui:component in JSF 2.0, 2.1, 2.2. ui:fragmentui:component在JSF rendered是有效的属性。 See JSF 2.2 View Declaration Language . 请参见JSF 2.2视图声明语言

Some IDEs do not propose this attribute in autocomplete (content assistant) mode and validate it as "Unknown attribute". 某些IDE不会在自动完成(内容助手)模式下建议此属性,而是将其验证为“未知属性”。 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. 发生这种情况是因为JSF 2.0中的标记文件声明中缺少rendered属性(即使该属性在UIComponent中提供了),并且IDE验证基于标记文件声明。 Issue was fixed in JSF 2.1: the missing attribute was added into the tag file declaration. 问题在JSF 2.1中已修复:缺少的属性已添加到标记文件声明中。 Validation in IDE not always reflect to this change. IDE中的验证并不总是能反映出这一变化。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM