使用非String参数的JSF调用方法

时间:2014-02-21 15:10:02

标签: eclipse jsf facelets jsf-2.2 glassfish-4

我有我的JSF:

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

action在eclipse(kepler JEE)中用红色加下划线并显示:

  

方法必须有签名“String method(),String method(),String method(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    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 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 method(String,    String,String,String,String,String,String,String,String,String,String,String,String,String,String,String    String,String,String,String)“但具有签名”字符串方法(电影,整数)“

该方法定义为:

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

当我按下按钮时它正确运行 - 这是日食中的错误还是我做错了什么?

编辑:正确运行:

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

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

太过reported

1 个答案:

答案 0 :(得分:1)

Passing parameter to JSF action

中引用@BalusC
  

当您使用web.xml定位Servlet 3.0容器(Tomcat 7,Glassfish 3,JBoss AS 6等)时,其根声明定义Servlet 3.0,那么您应该能够直接将参数传递给EL的动作方法,因为EL 2.2支持它(它是Servlet 3.0的一部分)。

你的方式应该是完全正确的,我想这是eclipse kepler中的一个错误。