Repository navigation
Fix composite and include listeners, and try the listener method taking the event first - #6158
Merged
Merged
Conversation
ContextualCompositeMethodExpression.invoke() throws the original MethodNotFoundException when the outer composite method expression does not resolve, so the caller falls back to the other variant. f:event and f:ajax try the listener method taking the event first, on each invocation, as MethodExpressionActionListener does. In Development, JSF1113 warns once per listener when the bean also has the method taking no arguments. valueChangeListener creates both variants through the tag attribute, so a method without arguments resolves the variables of an include or tag file. Fixes #6157 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
BalusC
force-pushed
the
listener_one_arg_first
branch
from
November 11, 2026 11:47
1f68db3 to
f187647
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #6157
<f:event listener>,<f:ajax listener>,actionListenerandvalueChangeListeneraccept a method taking the event or a method taking no arguments. Mojarra creates aMethodExpressionper variant and falls back to the other one onMethodNotFoundException.Composite component listeners.
ContextualCompositeMethodExpression.invoke()looks for the method expression of an outer composite component when its delegate throwsMethodNotFoundException. When that lookup failed withPropertyNotFoundException, it threw that one, so the caller never fell back to the other variant. A compositeactionListenerorvalueChangeListenerwith a bean method without arguments failed with HTTP 500. A composite<f:event>or<f:ajax>listener with amethod-signaturetaking the event gotnullas event on GlassFish, and failed on Tomcat. The lookup is now extracted intoinvokeOuterCompositeMethodExpression(), which throws the originalMethodNotFoundExceptionwhen the outer expression does not resolve or is no method expression. Any other exception of the lookup or of the invoked outer method still propagates.valueChangeListenerin an include or tag file.EditableValueHolderRulenow creates the variant without arguments through the tag attribute, asActionSourceRuledoes, and passes both variants toMethodExpressionValueChangeListener(MethodExpression, MethodExpression). The one-argument constructor created that variant without the variable mapper of the Facelet context, so a method without arguments of a bean fromui:paramor a tag file attribute failed with "Target Unreachable".Order.
<f:event>and<f:ajax>now try the variant taking the event first, on each invocation, asMethodExpressionActionListener.processAction()specifies.ListenerMethodInvokerdoes this for both tags.Behavior change. For
<f:event>and<f:ajax>, a bean which has bothm()andm(event)now getsm(event), asactionListenerandvalueChangeListeneralready do, and as MyFaces does for<f:event>. The same holds for a method taking varargs, which now gets the event. In Development stage, Mojarra logs JSF1113 once per listener for a bean with both methods. The specification does not define this case yet, see jakartaee/faces#2274.Tests:
ListenerMethodInvokerTest,DeserializedListenerTest,ContextualCompositeMethodExpressionTest, andIssue6157ITwith 37 cases, green on GlassFish. The IT covers every row of the table in jakartaee/faces#2274, and these listener syntaxes on all four attributes:#{b.m()},#{b.m(component)},#{b.m('x')},#{b['m']}, a method taking a supertype of the event,Objector varargs, a method returning a value, a bean fromui:param, a tag file attribute or a composite component attribute, a method call given to a composite component method attribute,c:forEach,ui:repeatandh:dataTablewith the var as argument,f:actionListenerandf:valueChangeListenerwithbinding="#{b.m()}", andui:repeatover beans of different classes. Against the 4.0 branch, 11 of them fail.🤖 Generated with Claude Opus 5.5