开发者

How can I check if a Resource Bundle contains a specific key in a JSF page

开发者_如何学Go

I have a JSF page which has a bundle loaded. However I need to dynamiclly build a key to access the property. What I need to do is check that the property exists so I can decide whether to render the or not.

I have tried checking if the value is empty but it always renders the output.

Thanks


You can write a custom JSTL / Facelets function that takes two arguments - the bundle and the key, and verifies whether the key is contained. Something like:

value="#{cust:containsKey(msg, key) ? msg[key] : 'default'}"


It's usually a plain Resourcebundle object, so you can use its method:

<h:panelGroup rendered="#{res.containsKey('myKey')}">...
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜