f:viewAction上的render属性的目的是什么? [英] What is the purpose of rendered attribute on f:viewAction?

查看:90
本文介绍了f:viewAction上的render属性的目的是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在官方我当时想,如果它包含一个计算结果为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属性评估时间的受害者.使用viewActionif属性更加安全,因为它的唯一目的是用例:

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆