JSF:呈现的属性 [英] JSF: rendered attribute

查看:144
本文介绍了JSF:呈现的属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有渲染属性的panelGroup.如果将rendered属性设置为false,为什么甚至会调用panelGroup中的组件值?我在这里误解了呈现的属性吗?

I have a panelGroup with a rendered attribute. Why is it that the component values in the panelGroup are even called if the rendered attribute is set to false? Do I missunderstand the rendered attribute here?

我想做的是:在panelGroup之前有一个selectManyCheckbox,只有当用户在selectManyCheckbox中选择了值并按下按钮时,才会执行panelGroup中的所有操作.这不会像这样工作,因为panelGroup中的组件取决于用户必须在selectManyCheckbox中选择的值.

What I want to do is: I have a selectManyCheckbox before the panelGroup and everything in the panelGroup should only be executed if the user has chosen values in the selectManyCheckbox and hit a button. This won't work like this because the components in the panelGroup depend on the values the user has to choose in the selectManyCheckbox.

<h:selectManyCheckbox /> // for the user to choose
<h:commandButton /> // to render the panelGroup

<h:panelGroup rendered="#{someBean.render}">
  <h:dataTable value="#{someOtherBean.loadSomething(someObject)}" var="item">
    // ...
  </h:dataTable>         
</h:panelGroup>

推荐答案

rendered属性仅说明是否应在客户端DOM上呈现以下组件.这些组件仍将跟随JSF生命周期事件,并保持托管bean的价值.

The rendered attribute simply states if the following component should be rendered on the client side DOM. These components will still follow the JSF lifecycle events and will maintain the value of a managed bean.

响应解决方法的请求:

如果不希望value属性调用bean方法,那么我可以看到解决此问题的最简单方法,只需对呈现条件进行if检查,即可将逻辑包装在bean方法中.

The simplest way I can see to workaround this, if you do not want the value attribute to invoke the bean method then simply wrap the logic in your bean method with an if check on the render condition.

public void loadSomething(Object someObject) {
  if (render()) {
    //Do loadSomething logic
  }
}

这篇关于JSF:呈现的属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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