3
<ui:repeat value="#{admin.detailTypesList}" var="detailType">
<h:outputText value="#{admin.getDetailTypeTranslation('ContactDetailType_'+detailType)}"/>
</ui:repeat>

for the el expression:

#{admin.getDetailTypeTranslation('ContactDetailType_'+detailType)}

The parameter passed to getDetailTypeTranslation is 'ContactDetailType_' (without the detailType value)

What am I doing wrong?

Ben
  • 10,020
  • 21
  • 94
  • 157
  • possible duplicate of [JSP EL String concatenation](http://stackoverflow.com/questions/3189642/jsp-el-string-concatenation) – McDowell May 31 '11 at 14:13
  • @McDowell not quite. This problem also requires the knowledge of using a el variable in a concatenation expression. – Ben May 31 '11 at 15:34

2 Answers2

5

In EL, the + is exclusively a sum operator. You can use <ui:param> to create a new variable which exist of a string concatenated with an EL expression and then use the new variable instead.

<ui:repeat value="#{admin.detailTypesList}" var="detailType">
    <ui:param name="contactDetailType" value="ContactDetailType_#{detailType}" />
    <h:outputText value="#{admin.getDetailTypeTranslation(contactDetailType)}"/>
</ui:repeat>

Please note that this problem is not related to JSF, but to EL in general.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
0

jsf's EL doesn't really have the concat operation ('+'). You should write a function to do it or use a bean method.

Vladimir Ivanov
  • 42,730
  • 18
  • 77
  • 103