How to compare an EL expression against the result

2019-01-20 16:26发布

I have following attribute in my Facelet:

rendered="#{createTicketBaseBean.show == '#{I18N['key_please_select']}'}"

I am trying to compare the value with property in my properties file, but I get following error:

Error Parsing: #{createTicketBaseBean.show == '#{I18N['key_value_incident']}'}`

But when I replace the above expression with a hard coded value like below:

rendered="#{createTicketBaseBean.show == 'incident'}"

Then it works fine. How do I properly compare against another EL expression?

标签: jsf-2 el
1条回答
放荡不羁爱自由
2楼-- · 2019-01-20 16:49

This is indeed invalid syntax. You can't and shouldn't nest EL expressions. You should see the #{} as one whole scope where variables can interact with each other.

Given your desired comparison

createTicketBaseBean.show == I18N['key_please_select']

this is the proper syntax:

rendered="#{createTicketBaseBean.show == I18N['key_please_select']}"
查看更多
登录 后发表回答