Eclipse Facelet HTML Validator:无法将表达式运算符应用于方法绑定

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20928595/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 21:27:28  来源:igfitidea点击:

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

eclipsevalidationjsf-2faceletsel

提问by Candice

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

Eclipse Facelet HTML 验证器针对以下行报告错误“无法将表达式运算符应用于方法绑定”:

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

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

我在Juno 帮助中找到了这个(我正在使用开普勒):

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!

我无法理解为什么将其结果视为值是不合法的?那么编写 EL 的正确方法是什么?谢谢!

回答by pasql

If you like you can hide the error message by setting

如果您愿意,可以通过设置隐藏错误消息

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

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

the value Applying method operator to bindingto Ignore.

Applying method operator to bindingIgnore

回答by Rash

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.

通过这种方式,JSF 会评估该方法,然后检查是否为 null 或为空。

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

我不是 JSF 方面的专家,但我在一个类似的表达式中遇到了同样的问题:

#{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.

我看到了 Eclipse 显示的相同问题,但页面运行正常。在我的两个表达式周围加上括号后,Eclipse 没有显示该错误。