What is wrong in this expression?

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

for the expression el:

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

The parameter passed in getDetailTypeTranslationis 'ContactDetailType_'(without value detailType)

What am I doing wrong?

+3
source share
2 answers

In EL, it +is the sole operator of the amount. You can use <ui:param>to create a new variable that exists from a string concatenated with an EL expression and use a 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.

+5
source

jsf EL really has no concat ('+') operation. You must write a function for this or use the bean method.

0
source

All Articles