JSF: ExpressionLanguage if else expression



我该怎么做?我想显示来自实体的值,而不是字符串,但是如何将其作为有效代码来执行此操作?

itemLabel="#{mandatoryFriendship.receiver == loginBean.currentMandatory ? mandatoryFriendship.sender.surname  : mandatoryFriendship.receiver.surname mandatoryFriendship.receiver.name}"

谢谢你的帮助

假设至少为 EL 2.2 并且名称为非空字符串,您可以拥有以下形式的表达式:

#{condition ? str0 : str1.concat(str2)}

对于旧版本(或空字符串),您可以使用:

#{condition ? str0 : str1}#{condition ? str0 : str2}

最新更新