Ben
Ben

Reputation: 10298

what's wrong in this el expression?

<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?

Upvotes: 3

Views: 252

Answers (2)

BalusC
BalusC

Reputation: 1109655

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.

Upvotes: 5

Vladimir Ivanov
Vladimir Ivanov

Reputation: 43108

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

Upvotes: 0

Related Questions