67

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>

In the backing bean there's this method:

public void downloadItem(Item item) {
    // ...
}

Everything works fine (when clicked the method is executed), but Eclipse validation fails with this strange message:

Method must have signature "String method(), String method(), String method(String), String method(String, String), String method(String, String, String), String method(String, String, String, String), String method(String, String, String, String, String), String method(String, String, String, String, String, String), String method(String, String, String, String, String, String, String), String method(String, String, String, String, String, String, String, String), String method(String, String, String, String, String, String, String, String, String), String method(String, String, String, String, String, String, String, String, String, String), String method(String, String, String, String, String, String, String, String, String, String, String), String method(String, String, String, String, String, String, String, String, String, String, String, String), String method(String, String, String, String, String, String, String, String, String, String, String, String, String), String method(String, String, String, String, String, String, String, String, String, String, String, String, String, String), String method(String, String, String, String, String, String, String, String, String, String, String, String, String, String, String), String method(String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String), String method(String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String), String method(String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String), String method(String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String)" but has signature "void method()"

What can I do?

If that's relevant, I'm using Eclipse Indigo SR1 on Tomcat 7.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
hugri
  • 1,416
  • 3
  • 18
  • 32

1 Answers1

135

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).

enter image description here

Image borrowed from this blog in all courtesy.

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 ;)

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.

See also:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • 1
    thanks - you're a real genius :-) and I fully agree on your Eclipse verdict ;) – hugri Nov 10 '11 at 18:19
  • 8
    Thank you very much, this error was very frustrating... also I see that you're the same person who wrote those awesome tutorials I'm following, so thank you for that as well. – Asaf Feb 08 '12 at 12:54
  • 1
    FYI: under IBM's pressure this Eclipse issue has *finally* been fixed this month. – BalusC Aug 27 '14 at 12:43
  • @BalusC good it's fixed, sad it needed pressure from IBM. Clearly WTP developers don't use their own tools to build JSF apps! – dexter meyers Oct 24 '14 at 13:23
  • Based on your impressive answer, I believe changing the method signature to `public String downloadItem(Item item) { ...; return null; }` would make Eclipse happy without any change in app behavior, right? – MestreLion Jun 20 '20 at 16:33