开发者

what's wrong in this el expression?

开发者 https://www.devze.com 2023-03-09 05:48 出处:网络
<ui:repeat value=\"#{admin.detailTypesList}\" var=\"detailType\"> <h:outputText value=\"#{admin.getDetailTypeTranslation(\'ContactDetailType_\'+detailType)}\"/>
<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 'ContactDetailT开发者_StackOverflowype_' (without the detailType value)

What am I doing wrong?


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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消