[英]Hiding JSF elements with Java
The java code returns a column from a SQL query and if the item isn't null, sets the title to "Available". java代码从SQL查询返回一列,如果该项不为null,则将标题设置为“Available”。
String sppAcronym = results.getString("ACRONYM");
if (sppAcronym != null) {
sp.setFireStudyTitle("Available");
}
The JSF code makes a button labeled "Available" for all of the non-null items. JSF代码为所有非null项创建一个标记为“Available”的按钮。
<h:column headerClass="columnHeader" footerClass="columnFooter" itemValue="0">
<f:facet name="header">Link to FEIS Fire Studies</f:facet>
<h:commandButton id="btnSearch" value="#{SPP.fireStudyTitle}"
action="#{searchBean.doMagic(SPP.acronym)}"
immediate="true" onchange="submit();"
style="font-weight:bold; font-size:small;"
onclick="javascript:cursor_wait()" class="buttonsFEIS"/>  
</h:column>
My problem is that JSF makes small, empty commandButtons even for the null items. 我的问题是,即使对于null项,JSF也会创建小的空commandButtons。
How can I make it so I can hide those empty commandButtons and display only the non-null items? 我怎么能这样做,所以我可以隐藏那些空的commandButtons并只显示非空项目?
Use rendered
attribute of the <h:commandButton>
to control if the component must display or not in the generated HTML: 使用
<h:commandButton>
rendered
属性来控制组件是否必须在生成的HTML中显示:
<h:commandButton id="btnSearch" value="#{SPP.fireStudyTitle}"
action="#{searchBean.doMagic(SPP.acronym)}"
immediate="true" onchange="submit();"
style="font-weight:bold; font-size:small;"
onclick="javascript:cursor_wait()" class="buttonsFEIS"
rendered="#{not empty SPP.acronym}" />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.