The best place to *find* answers to programming/development questions, imo, however it's the *worst* place to *ask* questions (if your first question/comment doesn't get any up-rating/response, then u can't ask anymore questions--ridiculously unrealistic), but again, a great reference for *finding* answers.

My Music (Nickleus)

20131001

richfaces jsf xhtml - how to append/concat/concatenate string from backing bean value to messages message label in EL expression

here's normal code for a normal label:
<h:outputText value="#{msg['general.costdeviation.status.accepted']}" id="status" />

which will output the locale-dependent text for the label general.costdeviation.status.accepted, e.g. for english:
Accepted


but what if i want to dynamically ask for labels depending on the postfix, e.g. if i have multiple labels with an identical prefix, e.g.:
general.costdeviation.status.accepted=Accepted
general.costdeviation.status.negotiating=Negotiating
general.costdeviation.status.open=Open
general.costdeviation.status.proposed=Proposed


here's how you'd do it, dynamically:
<h:outputText value="#{msg['general.costdeviation.status.'.concat(detail.status)]}" escape="false" id="status" />

where the backing value for #{detail.status} can be one of the following:
accepted
negotiating
open
proposed




thanks to this post: Concatenating strings within EL expression defined in an attribute of a facelets tag

No comments:

Post a Comment