[ https://issues.apache.org/jira/browse/MYFACES-4712?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17930242#comment-17930242 ]
Werner Punz commented on MYFACES-4712: -------------------------------------- Already did in conjunction with another bug yesterday. The issue is following. The id of the source element is basically passed down and then on each event a lookup is performed, if a page change or element change occurs the source element might not be present in the page anymore. The fix simply is to make an initial lookup and then store the source element in the internal context. for the other events. But no gurantee that the source element still is present in the page at done. This is clearly a bug in the new ts codebase and I will offer a fix this week (already have it on my hd but I still need to write tests for it!) > 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 > > 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)