我有ap:outputPanel,如果我有一个带有数据的Java对象,我想渲染它.如果对象为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;
}
}
Run Code Online (Sandbox Code Playgroud)
我注意到代码工作正常.如果对象为null,则布尔值为false,并且不显示面板.但是我发现的问题是,当我再次进行AJAX调用时,无论Java对象是否为null,布尔值总是为false.我可以在AJAX调用之后以某种方式配置p:outputPanel以检查#{TreeViewController.compProfile}
属性是否呈现面板.
更改
<p:outputPanel id="outputComponent" rendered="#{TreeViewController.compProfile}">
Run Code Online (Sandbox Code Playgroud)
成
<p:outputPanel autoUpdate="true">
<p:outputPanel id="outputComponent" rendered="#{TreeViewController.compProfile}">
</p:outputPanel>
Run Code Online (Sandbox Code Playgroud)
或者不添加包装器并将treeform
id 添加到update
ajax(p:ajax
或p:commandButton
)的attribue中
像这样 update="treeform"
归档时间: |
|
查看次数: |
5194 次 |
最近记录: |