[ https://issues.apache.org/jira/browse/MYFACES-4712?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17930452#comment-17930452 ]
Werner Punz edited comment on MYFACES-4712 at 2/25/25 9:43 PM: --------------------------------------------------------------- The issue is fixed now, a unit test which proofs the validity of the fix has been added to the tests. was (Author: werpu): The issue is fixed now, a unit test which proofs the fix has been added to the tests. > ajax event listener looses 'source' in 'success' event > ------------------------------------------------------ > > Key: MYFACES-4712 > URL: https://issues.apache.org/jira/browse/MYFACES-4712 > Project: MyFaces Core > Issue Type: Bug > Components: General > Affects Versions: 4.0.2 > Reporter: Milo van der Zee > Assignee: Werner Punz > Priority: Major > Fix For: 5.0.0, 4.0.3, 4.1.1 > > > I'm adding an event listener for the ajax events. I do this by calling > `faces.ajax.addOnEvent(onEventFunction)` and I expect all forwarded events to > have the 'source' value set to the original source that triggered the ajax > flow. But this does not seem to work when switching to a different page. It > works fine when the view stays on the same page. > This used to work in 2.3.x versions and is needed by RichFaces. > See [https://github.com/MilovdZee/myfaces-minimal-test] for an example of > this behaviour. > {code:java} > function onEventFunction(data) { > console.log(data); > } > faces.ajax.addOnEvent(onEventFunction);{code} > And then in the xhtml of page 1: > {code:java} > <h:commandLink id="button" value="to page 2" > action="#{pageSwitcherBean.toPage2()}"> > <f:ajax/> > </h:commandLink> {code} > A plain commandbutton has no issue and the source is preserved in all > statusses: > {code:java} > <h:commandButton id="button2" value="delay" > actionListener="#{pageSwitcherBean.toPage2()}"> > <f:ajax/> > </h:commandButton> {code} > > My expectation is that this has to do with the render of the elements. The > source dom element disappears due to the fresh rendering of the page. > And this also means that it does not sound that weird that the source is > null. The element is gone anyway and so the meaning is minimal. But it very > much looks like it used to be there. > For reference I also added the same functionality with myfaces 2.3.11. With > 2.3.11 everything works as expected. The source is also available in the > SUCCESS event. -- This message was sent by Atlassian Jira (v8.20.10#820010)