I have run into a weird situation. I have an application which was originally developed in RAD and uses a construct like
rendered="#{bean.show and user.can('foo')}"
Our developers use mix of RAD and Eclipse Juno / Kepler. So we need to make the code work in both the environments.
In RAD, the above line does not generate any errors. When I export the project as archive and import it into Eclipse Juno, it generates this error
Cannot apply expression operators to method bindings
Our environment is Websphere 8.5, RAD / Eclipse, JSF 2.1
How can I fix this?
In general, if you face a false EL validation error in a JSF file in Eclipse, try peeking around in Window > Preferences > Web > JavaServer Faces Tools > Validation and tune some settings currently (unnecessarily) set at Error.
Your particular problem is triggered by "Applying operator to method binding" which indeed defaults to Error. If upgrading Eclipse to most recent version is somehow not an option, setting it back to Warning should tone down it.
After all, EL validation in Eclipse is quite an epic fail. It seems like it's using regular expressions to validate EL syntax instead of a true stack based parser like as EL itself is doing. There are several entries below "Type Coercion Problems" and "Type Assignment Problems" which are unnecessarily set to Error and known to cause false errors.
I had the same error with any of these statements:<h:panelGroup rendered="#{!bean.isValid(obj)}">
<h:panelGroup rendered="#{not bean.isValid(obj)}">
I resolved the error by changing the statement as follows:<h:panelGroup rendered="#{bean.isValid(obj) == false}">
I found yet another example that resolved the problem:<ui:fragment rendered="#{bean.isValid(obj) eq 'false'}">
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With