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
  • 9,510
  • 21
  • 90
  • 153
  • 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,040,783
  • 362
  • 3,548
  • 3,513
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,109
  • 17
  • 76
  • 102