0

データを含む Java オブジェクトがある場合にレンダリングしたい ap:outputPanel があります。オブジェクトが null の場合、パネルをレンダリングしたくありません。

<h:form id="treeform">
    <p:outputPanel id="outputComponent" rendered="#{TreeViewController.compProfile}">
        <div>
            .........
        </div>
    </p:outputPanel>
</h:form>

public boolean getCompProfile()
{

    if (cd == null)
    {
        return false;
    }
    else
    {
        return true;
    }
}

コードが正常に機能していることに気付きました。オブジェクトが null の場合、ブール値は false になり、パネルは表示されません。しかし、私が見つけた問題は、Java オブジェクトが null であるかどうかに関係なく、AJAX 呼び出しを再度行うと、ブール値が常に false になることです。AJAX 呼び出しの後に p:outputPanel を何らかの方法で構成して、#{TreeViewController.compProfile}プロパティをレンダリングするかどうかをチェックできますか?

4

1 に答える 1

9

変化する

<p:outputPanel id="outputComponent" rendered="#{TreeViewController.compProfile}">

の中へ

<p:outputPanel autoUpdate="true">
    <p:outputPanel  id="outputComponent" rendered="#{TreeViewController.compProfile}">
</p:outputPanel>

または、ラッパーを追加せず、treeformid をupdateajax の属性に追加します (p:ajaxまたはp:commandButton)

このようなupdate="treeform"

于 2013-02-11T22:51:47.887 に答える