1

can I 'build' my resource bundle key within a jsf servlet?

Something like this:

<cc:myComponent type="person" />
<cc:myComponent type="payment" />

myComponent:

<composite:attribute name="type" />

<h:outputText value="message.xx.type" />

bundle:

message.xx.person = i'm a person
message.xx.payment = i'm a payment

Possible somehow?

membersound
  • 81,582
  • 193
  • 585
  • 1,120

1 Answers1

0

If you are using EL 2.2 it can be done using following code at component's implementation section:

<h:outputText value="#{'message.xx.'.concat(cc.attrs.type)]}" />

The issue is regarding concatenating strings in EL and there is another question about it: Concatenate strings in JSF/JSP EL and Javascript

If you are not using EL 2.2 then you will find the answer at the same question I've just linked here.

Community
  • 1
  • 1
Alonso Dominguez
  • 7,750
  • 1
  • 27
  • 37
  • Yes I might be using EL 2.2, or rather just added it to maven. Though cannot get it to work? – membersound Mar 27 '12 at 08:29
  • Ok sorry, I missed the dot after xx. So it really works, very nice. tyvm! Only left: eclipse is complaining about not resolving the bundle key. Can I somehow teach eclipse to being able to handle these kind of expressions? – membersound Mar 27 '12 at 08:36
  • can't help you with that, I use IntelliJ IDEA as my IDE, I think you will need to ask another question for that... – Alonso Dominguez Mar 27 '12 at 09:12