JSF EL表达式检查属性文件中的空字符串? [英] JSF EL expressions to check empty string in propery file?

查看:118
本文介绍了JSF EL表达式检查属性文件中的空字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须检查某些标签的属性文件是否为空,因为我必须渲染元素,但是即使标签为空,我仍然会得到显示键的元素:

I have to check if my property file is empty for certain label based on that I have to render the element but even when the label is empty i still get the element displaying key:

           <h:panelGroup  rendered="#{not empty I18N['key_hint_message'] }">
          <h:outputLabel id="hint_label" value="#{I18N['key_label_hint']}
           "></h:outputLabel>
          <h:outputText value="#{I18N['key_hint_message']}" ></h:outputText>
          </h:panelGroup>


推荐答案

您可以使用 ResourceBundle#containsKey()

You can use ResourceBundle#containsKey() for this.

<h:panelGroup rendered="#{I18N.containsKey('key_hint_message')}">
    <h:outputLabel value="#{I18N['key_label_hint']}" />
    <h:outputText value="#{I18N['key_hint_message']}" />
</h:panelGroup>

您最好不要依赖丢失键的默认格式,因为它可以被自定义资源覆盖包解析器。

You'd better not rely on default format of missing keys as this can be overriden by a custom resource bundle resolver.

这篇关于JSF EL表达式检查属性文件中的空字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆