Candice
Candice

Reputation: 321

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

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!

Upvotes: 23

Views: 20219

Answers (2)

Rash
Rash

Reputation: 8227

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.

Upvotes: 24

pasql
pasql

Reputation: 3825

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.

Upvotes: 25

Related Questions