Call method with variable arguments from JSF 2.0

In the bean backup, I have declared the following method

public boolean hasPermission(Object... objects) {


And I'm trying to call it from JSF 2.0 like this:

<c:set var="hasPermission" scope="view" value="#{restrictions.hasPermission(entity)}" />


And he throws

javax.el.ELException:  Cannot convert Entity of class com.testing.Entity to class [Ljava.lang.Object;


If I pass two arguments, then it throws

Method hasPermission not found


Is it possible to somehow call varargs methods from JSF 2.0?


source to share

2 answers

Varargs is not officially supported in EL. At least it's not specified anywhere in the EL spec. There are also no plans to introduce it in the upcoming EL 3.0 .

You need to look for another solution. Since the functional requirement is unclear, I can't suggest anyone.

Update it seems that the Apache EL parser provided in Tomcat supports this. This is at least not supported by the Sun / Oracle EL parser provided by Glassfish.



In Tomcat 7 JSF 2.1.4 the following works

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<html xmlns=""
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Insert title here</title>
    <h:commandButton value="click 1"
    <h:commandButton value="click 2"
    <h:commandButton value="click 3"



public class Test {

    private Integer i = 10;
    private Double d = 10.0;
    private String s = "varargs";
    private String[] ss = new String[]{"1","2","3"};
    public Integer getI() {
        return i;
    public void setI(Integer i) {
        this.i = i;
    public Double getD() {
        return d;
    public void setD(Double d) {
        this.d = d;
    public String getS() {
        return s;
    public void setS(String s) {
        this.s = s;
    public String[] getSs() {
        return ss;
    public void setSs(String[] ss) { = ss;

    public void var(Object...objects){


Conclusion: on click 1,2,3

[a, b, 1, 10, 10.0, varargs, [Ljava.lang.String; @ 4fa9cba5]

[a, b, 1]

[10, 10.0, varargs, [Ljava.lang.String; @ 26b923ee]

This is what you are looking for .... since the way you are trying to call is empty.



All Articles