JSF 提出的问题
子元素的 EL 解析是否真的应该被评估?这给我带来了很多空指针异常和类似的麻烦。查看以下示例:
<p:tab title="#{userCompetenceController.getTreeName(3)}" rendered="#{!empty userCompetenceController.getTreeName(3)}">
<xdin:competenceTable id="competenceBox3"
profile="#{userCompetenceController.selectedProfile}"
tree="#{userCompetenceController.getCompetenceTree(3)}"
maxHeight="500px"/>
</p:tab>
主要问题(除了性能之外)是 xdin:competenceTable
不支持 null tree
属性。在这种情况下,getTreeName(int index)
返回 null,然后调用 getCompetenceTree(3)
,即使其父级 (p: tab
)有 rendered="false"
简而言之:xdin:competenceTable
被 EL 解析,即使它的父级有 rendered="false"< /代码>。为什么?
Is EL-parsing of children to elements with rendered="false" really supposed to be evaluated? This is causing me alot of trouble with null pointer exceptions and similar. Looking at the following example:
<p:tab title="#{userCompetenceController.getTreeName(3)}" rendered="#{!empty userCompetenceController.getTreeName(3)}">
<xdin:competenceTable id="competenceBox3"
profile="#{userCompetenceController.selectedProfile}"
tree="#{userCompetenceController.getCompetenceTree(3)}"
maxHeight="500px"/>
</p:tab>
The main issue (besides performance) is that xdin:competenceTable
does not support a null tree
-attribute. getTreeName(int index)
returns null in this case, and is followed by a call to getCompetenceTree(3)
which returns null, even though its parent (p:tab
) has rendered="false"
In short: xdin:competenceTable
is parsed by EL even though it's parent has rendered="false"
. Why?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看一下下面的 JSF 生命周期。
渲染只是最后一个阶段,rendered="false"
仅影响最后一个阶段,而构建组件时的错误发生在第一个阶段。非渲染组件事实上,在所有阶段都不应该做任何事情,但看起来你的组件不符合规范的这一部分。
Take a look at the JSF lifecylce below.
Rendering is only the last phase, andrendered="false"
only affects that last phase, while errors in constructing a component happen in the first.Non-rendered components should in fact not do anything during all phases, but it looks as though your component does not conform to that part of the spec.