2

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

1
  • by empty you mean an empty String or null ?
    – Redlab
    Jun 14, 2010 at 15:55

2 Answers 2

1

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'}"
1

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

<h:panelGroup rendered="#{res.containsKey('myKey')}">...
1
  • Note that EL 2.2 wasn't commonly available at the date this question was asked. Before EL 2.2 was introduced, this line would throw an EL syntax error.
    – BalusC
    Sep 21, 2016 at 14:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.