问题描述
我有一个数据表,每一行都有一个按钮:
I have a datatable with a button in each row:
<ice:dataTable ... var="item">
<ice:column>
<h:commandButton value="Download" action="#{mybean.downloadItem(item)}" />
</ice:column>
</ice:dataTable>
在支持bean中有以下方法:
In the backing bean there's this method:
public void downloadItem(Item item) {
// ...
}
一切正常(点击执行该方法),但
Eclipse验证失败,出现这个奇怪的消息:
Everything works fine (when clicked the method is executed), butEclipse validation fails with this strange message:
方法必须有签名String method(),String method(),String
method(String),String method(String,String),String method(String,
String,String),String方法(String,String,String,String),String
方法(String,String,String,String,String),String方法(String,
String,String,String ,String,String),String方法(String,String,
String,String,String,String,String),String方法(String,String,
String,String,String,String,String,String ),String方法(String,
String,String,String,String,String,String,String,String),
String方法(String,String ,String,String,String,String,String $ String $ String String String String String String String String String String String String String String String String String String String String String String String String String String String String String String String String String String String String String String String String String String ),String
方法(String,String,String,String,String,String,String,String,
String,String,String,String),String方法(String,String,String,
,String,String,String,String,String,String,String,String,
String,String),String方法(String,String,String,String,String,
String,String,String,String ,String,String,String,String,
String),String方法(String,String,String,String,String,String,
String,String,String,String,String,String,String,String ,
String),String方法(String,String,String,String,String,String,
String,String,String,String,String,String,String,String,
String,String ),String方法(String,String,String,String,String,
String,String,String,String,String,String,St ring,String,
String,String,String,String),String方法(String,String,String,
String,String,String,String,String,String,String,String,
String,String,String,String)String
方法(String,String,String,String,String,String,String,String,
String,String,String,String,字符串,字符串,字符串,
字符串,字符串,字符串)但具有签名void method()
我可以做什么?
如果相关,我在Tomcat 7上使用Eclipse Indigo SR1。
If that's relevant, I'm using Eclipse Indigo SR1 on Tomcat 7.
推荐答案
忽略它。 Eclipse是一个混蛋。您可以通过将窗口>首选项> Web> JavaServer Faces工具>验证>类型分配问题>方法表达式签名不兼容性设置为警告或忽略(默认为错误)
Ignore it. Eclipse is a jerk. You can tone it by setting Window > Preferences > Web > JavaServer Faces Tools > Validation > Type Assignment Problems > Method expression signature incompatibility to Warning or Ignore (it defaults to Error).
原因是,Eclipse期望 code>属性始终返回
String
,而不是 void
。虽然在JSF action
属性中确实没有指定,EL方法表达式本身实际上也支持 void
方法。过热的消息反过来表明,负责此验证的基础逻辑不能确定单独的方法参数,因此它尝试将原始方法签名与允许的签名集合进行比较,如果没有匹配,则最终显示在消息中找到。基于该消息,当该方法具有20个或更多的参数时,这个问题也可能消失;)
The reason is, Eclipse expect the action
attribute to always return String
, not void
. Whilst indeed unspecified in JSF action
attribute, the EL method expressions themselves actually also support void
methods. The overzealous message in turn suggests that the underlying logic responsible for this validation is incapable of determining the individual method arguments and thus it tries to compare the raw method signature against a collection of allowed signatures, which ultimately get shown in the message if no match was found. Based on the message, this problem may also disappear when the method has 20 or more arguments ;)
这是在Eclipse Luna SR1中修复的,问题是近6年报道。严重性已从错误减少为警告。
This is fixed in Eclipse Luna SR1, nearly 6 years after the issue was reported. The severity has been decreased from Error to Warning. You may still want to put it yet lower to Ignore.
- Eclipse issue report 243674
- Differences between action and actionListener
这篇关于方法必须具有签名“String method()... [etc] ...”但是具有签名“void method()”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!