开发者

JSF: rendered attribute

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?

What I want to do is: I have a selectManyCheckbox befor开发者_运维知识库e 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>


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.

EDIT: In response to a request for a workaround:

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
  }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜