Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 409
Candice Avatar asked Jan 05 '14 00:01

Candice


2 Answers

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.

like image 175
pasql Avatar answered Nov 11 '22 20:11

pasql


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.

like image 25
Rash Avatar answered Nov 11 '22 19:11

Rash