JSF calling method with non String parameters
Asked Answered
K

1

0

I have in my JSF:

<h:commandButton value="Add to Cart"
    rendered="#{movieDisplayController.movie.available != 0}"
    action="#{cartController.addMovie(movieDisplayController.movie, '2')}">
</h:commandButton>

The action is underlined in red in eclipse (kepler JEE) and displays:

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 "String method(Movie, Integer)"

The method is defined as :

public String addMovie(Movie movie, Integer quantity) {
    //...
    return null;
}

It runs correctly when I hit the button - is it a bug in eclipse or am I doing something wrong ?

EDIT: runs also correctly with :

action="#{cartController.addMovie(movieDisplayController.movie, 2)}">

and

action="#{cartController.addMovie(movieDisplayController.movie,
    movieDisplayController.quantity)}">

too so reported

Kaslik answered 21/2, 2014 at 15:10 Comment(4)
It happened once to me, and looks like a bug in Eclipse, didn't go through it but glad I'm not alone on this.Goldfinch
possible duplicate of Method must have signature "String method() ...[etc]..." but has signature "void method()"Spy
@BalusC: not exactly a duplicate - the issue here is the Integer parameter - reported it and it is scheduled for Luna (hold a small basket)Kaslik
The use case is perhaps different, but the problem has under the covers definitely the same cause.Spy
V
1

Quoting @BalusC in Passing parameter to JSF action

When you're targeting a Servlet 3.0 container (Tomcat 7, Glassfish 3, JBoss AS 6, etc) with a web.xml whose root declaration definies Servlet 3.0, then you should be able to just pass the parameter straight into the action method by EL as that's supported by EL 2.2 (which is part of Servlet 3.0).

your way should be completely right, and I guess it's a bug in eclipse kepler.

Vientiane answered 21/2, 2014 at 15:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.