f:viewAction上的render属性的目的是什么? [英] What is the purpose of rendered attribute on f:viewAction?
问题描述
在官方我当时想,如果它包含一个计算结果为false的表达式,则action
表达式将不会像下面的示例那样被执行:
I was thinking that, if it contained an expression that evaluated to false, the action
expression would not be executed like in the following example:
<f:viewAction
action="#{javax.enterprise.context.conversation.begin()}"
rendered="#{javax.enterprise.context.conversation.isTransient()}"
/>
但是action
总是执行,无论rendered
属性的计算结果是什么.
But the action
is always executed no matter what the rendered
attribute evaluates to.
那么它的目的是什么?
推荐答案
您可能是rendered
属性评估时间的受害者.使用viewAction
的if
属性更加安全,因为它的唯一目的是用例:
You're probably a victim of the timing of the evaluation of the rendered
attribute. You're safer using the if
attribute of the viewAction
as it's sole purpose is your use case:
<f:viewAction action="#{javax.enterprise.context.conversation.begin()}"
if="#{javax.enterprise.context.conversation.isTransient()}"/>
if
属性仅在评估为true
时才执行视图操作,并且它是JSF2.2的新功能
The if
attribute executes the view action only if it evaluates to true
, and it's new with JSF2.2
相关:
这篇关于f:viewAction上的render属性的目的是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!