JSF EL expressions to check empty string in propery file?

百般思念 提交于 2019-12-02 10:41:59

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 implementation displays by defaults missing resources as ???resource???, So you can use the fn:contains JSTL function in your rendered attribute like this:

 <h:panelGroup  rendered="${not fn:contains(I18N['key_hint_message'], '???')}">
      <h:outputLabel id="hint_label" value="#{I18N['key_label_hint']}"/>
      <h:outputText value="#{I18N['key_hint_message']}" />
 </h:panelGroup>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!