Skip to main content

Passing ajax listener into a component

4 replies [Last post]
Joined: 2007-11-12

I have a simple composite component. Within that component, I have a command button with an attached f:ajax tag. If I specify the listener directly in the component, then everything works, like this:

If I remove that, and change the listener for a component attribute, then it throws an exception that says "wrong number of arguments."

The code that does _not_ work looks like this.


Am I specifying the method-signature wrong or something? Any help would be appreciated.


Here's the full trace of the final exception in the log
[java] Caused by: java.lang.IllegalArgumentException: wrong number of arguments
[java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[java] at sun.reflect.NativeMethodAccessorImpl.invoke(
[java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(
[java] at java.lang.reflect.Method.invoke(
[java] at
[java] at com.sun.el.parser.AstValue.invoke(
[java] at com.sun.el.MethodExpressionImpl.invoke(
[java] at com.sun.faces.facelets.el.ContextualCompositeMethodExpression.invoke(
[java] at com.sun.faces.facelets.tag.TagAttributeImpl$AttributeLookupMethodExpression.invoke(
[java] at com.sun.faces.facelets.tag.jsf.core.AjaxBehaviorListenerImpl.processAjaxBehavior(
[java] at javax.faces.event.AjaxBehaviorEvent.processListener(
[java] at javax.faces.component.behavior.BehaviorBase.broadcast(
[java] at javax.faces.component.UIComponentBase.broadcast(
[java] at javax.faces.component.UICommand.broadcast(
[java] at javax.faces.component.UIViewRoot.broadcastEvents(
[java] at javax.faces.component.UIViewRoot.processApplication(
[java] at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2004-05-06

Please take a look at the documentation for the VDL (View Description Language):

Declares that this attribute must be a MethodExpression whose method signature is described by the value of this attribute. The signature must be described using fully qualified class names wherever a type is required. This attribute is mutually exclusive with the "type" attribute. If both attributes are present, the "method-signature" attribute is ignored.

PENDING: when this file is generated from the web-facesuicomponent_2_0.xsd, we will not need to copy the content here manually.

Provides the signature of the Java method. The syntax of the method-signature element is as follows (taken from function-signature in web-jsptaglibrary_2_1.xsd):

MethodSignature ::= ReturnType S MethodName S? '(' S? Parameters? S? ')'

ReturnType ::= Type

MethodName ::= Identifier

Parameters ::= Parameter | ( Parameter S? ',' S? Parameters )

Parameter ::= Type



Type is a basic type or a fully qualified Java class name (including package name), as per the 'Type' production in the Java Language Specification, Second Edition, Chapter 18.

Identifier is a Java identifier, as per the 'Identifier' production in the Java Language Specification, Second Edition, Chapter 18.


java.lang.String nickName( java.lang.String, int )

Joined: 2007-11-12

Thanks for the pointer. I had actually already read that and am wondering which part of my attribute doesn't conform to the VDL specification. I tried changing the return type of void to java.lang.Void with no change in behavior. I was able to work around the problem by simply not passing the listener, but would like to figure out why it doesn't work.

Joined: 2010-07-15

yeah... i'm facing the same problem here... any progress with that?

Joined: 2007-11-12

Unfortunately, other than the workaround I mentioned in my previous post, I didn't make any progress. It seems that the best solution would be to expose the actionSource in your composite component, and then attach an f:ajax tag to it when you use the component like we are supposed to do with actionListeners and all that, but unfortunately, there's no "for" attribute in the f:ajax tag, so that's just not an option. Looks like the bug I filed on it ( ) isn't scheduled to be fixed any time soon.