0

How can I pass an arugument to listener method?

I have tried like this:

<p:poll interval="3" listener="#{vehicleController.onPoll('12')}"
    update="vehicleDataList"/>

and

<p:poll interval="3" listener="#{vehicleController.onPoll(vehicle.vehicleLicense)}"
    update="vehicleDataList"/>

But it throws the following exception:

javax.servlet.ServletException: /monitorVehicles/vehiclesList.xhtml
Failed to parse the expression [#{vehicleController.onPoll('12')}]

How can I achive this?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Venkat Maridu
  • 892
  • 3
  • 22
  • 45

2 Answers2

5

getting this exception "Failed to parse the expression [#{vehicleController.onPoll('12')}]"

Your environment doesn't support the new EL 2.2 feature of invoking methods with arguments.

EL 2.2 is part of Servlet 3.0, thus in order to utilize it, you need to deploy to a Servlet 3.0 compatible container (e.g. Tomcat 7, Glassfish 3, JBoss AS 6, etc) with a Servlet 3.0 compatible web.xml file. If you don't deploy to a Servlet 3.0 compatible container, or don't have a Servlet 3.0 compatible web.xml, then you aren't using EL 2.2 at all and you will get this kind of exception.

If you're actually targeting/deploying to a Servlet 2.5 compatible container (and thus using EL 2.1), then you can use JBoss EL to have the new EL 2.2-like features in EL 2.1.

See also:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
1

In JSF 2:

If your listener is expecting a string:

"#{vehicleController.onPoll('11')}"

public void onPOll(String s){

}

If your listener is expecting an int:

"#{vehicleController.onPoll(11)}"
public void onPoll(int i){

}
PermGenError
  • 45,977
  • 8
  • 87
  • 106