Eclipse Facelet HTML Validator: Cannot apply expression operators to method bindings
Asked Answered
B

2

23

The Eclipse Facelet HTML Validator reports an error "Cannot apply expression operators to method bindings" for the following line:

<ui:fragment rendered="#{!empty managedBean.getSomething('ENUM_VALUE', someInt)}">

I found this in the Juno help (I'm using Kepler):

Applying operator to method binding
#{bean.action * 5}
If bean.action indicates a method "action()" on bean, then it is not legal EL to treat its result as a value. In the example, multiplying action by 5 attempts treat it is as a value.

I'm having trouble understanding why it's not legal to treat its result as a value? What's the correct way to write the EL then? Thanks!

Battement answered 5/1, 2014 at 0:38 Comment(2)
See also: https://mcmap.net/q/584852/-eclipse-gives-too-many-false-errors-and-warnings-on-el-expressions-in-jsf-files/1725096Coracoid
The link above, in which BalusC says "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."Haldi
B
25

If you like you can hide the error message by setting

Window -> Preferences -> Web -> JavaServer Faces Tool -> Validation -> General Problems

the value Applying method operator to binding to Ignore.

Bushed answered 31/1, 2014 at 13:16 Comment(1)
Well, this is a fine mitigation for the Eclipse issue, but it does not show "the correct way to write the EL".Leannleanna
A
24

Have you tried putting paranthesis around your method. Like this:

#{!empty (managedBean.getSomething('ENUM_VALUE', someInt))}

This way JSF evaluates the method and then checks for null or empty.

I am no expert in JSF, but I had the same problem in one of the similar expression:

#{some_method() == 0 and some_other_method() eq 'some value'}

I saw the same issue shown by Eclipse but the page was running correctly. After I put paranthesis around both of my expressions, Eclipse did not show that error.

Artema answered 7/10, 2014 at 13:32 Comment(4)
I am learning here and would like to know the reason for downvote please. Thanks.Artema
I rechecked my answer. I recreated the situation. Eclipse does not show error when your method expression is under parantheseis. Please tell me why you downvoted my answer ?Artema
This worked! thanks. Idk why you were downvoted originally.Mathews
This is still present in Eclipse Neon.3 Release (4.6.3). But the code compile and run perfectly.Finegrained

© 2022 - 2024 — McMap. All rights reserved.