0

我们在 CAF portlet 中有两个 caf_h:panelBlock 元素(id="panel1"id="panel2"),它们应该基于支持 bean 的属性(rendered="#{ViewBean.property}"rendered="#{not ViewBean.property}")呈现。

所以这样一个面板的 XHTML 锁定如下:

<caf_h:panelBlock id="panel1" rendered="#{ViewBean.property}">
    content
</caf_h:panelBlock>

支持 bean 的属性声明如下:

private java.lang.Boolean property;

并在 bean 的 Initialize() 方法中初始化:

public String initialize() {
    this.property = true;
}

现在棘手的部分来了:我们想通过单击命令链接来显示/隐藏这些面板:

<caf_h:commandLink action="#{ViewBean.click}" id="commandLink"></caf_h:commandLink>

此命令链接调用的 bean 方法反过来会更改属性的值:

public String click() {
    this.property = false;
}

但是,块面板的可见性/渲染完全不受影响。可能是什么原因?

4

1 回答 1

0

事实证明,如果在 portlet 生命周期的后期没有再次更改,则上述方法可以正常工作ViewBean.property——就像我们在beforeRenderResponse()方法中意外所做的那样。

于 2018-03-01T10:59:40.710 回答