Skip to main content

Passing ajax listener into a component

4 replies [Last post]
jweight
Offline
Joined: 2007-11-12
Points: 0

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.

Joel

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(NativeMethodAccessorImpl.java:39)
[java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[java] at java.lang.reflect.Method.invoke(Method.java:597)
[java] at com.google.appengine.tools.development.agent.runtime.Runtime.invoke(Runtime.java:100)
[java] at com.sun.el.parser.AstValue.invoke(AstValue.java:187)
[java] at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:297)
[java] at com.sun.faces.facelets.el.ContextualCompositeMethodExpression.invoke(ContextualCompositeMethodExpression.java:164)
[java] at com.sun.faces.facelets.tag.TagAttributeImpl$AttributeLookupMethodExpression.invoke(TagAttributeImpl.java:443)
[java] at com.sun.faces.facelets.tag.jsf.core.AjaxBehaviorListenerImpl.processAjaxBehavior(AjaxHandler.java:436)
[java] at javax.faces.event.AjaxBehaviorEvent.processListener(AjaxBehaviorEvent.java:113)
[java] at javax.faces.component.behavior.BehaviorBase.broadcast(BehaviorBase.java:98)
[java] at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:763)
[java] at javax.faces.component.UICommand.broadcast(UICommand.java:300)
[java] at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:775)
[java] at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1267)
[java] at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:82)

Reply viewing options

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

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

Where:

*

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.

Example:

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

jweight
Offline
Joined: 2007-11-12
Points: 0

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.

drborges
Offline
Joined: 2010-07-15
Points: 0

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

jweight
Offline
Joined: 2007-11-12
Points: 0

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 ( https://javaserverfaces.dev.java.net/issues/show_bug.cgi?id=1710 ) isn't scheduled to be fixed any time soon.