How to compare an EL expression against the result

2019-01-20 16:54发布

问题:

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?

回答1:

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']}"


标签: jsf-2 el