Here is my markup:
<h:commandLink value="#{partial}" action="#{hello.setCurrentPartial(partial)}">
<f:ajax render="include" listener="#{hello.renderFragments}"/>
</h:commandLink>
I tried to run this page in Mojarra-2.2.8(wildfly 8.2.0.Final built-in) and MyFaces-2.2.7(installed as guided here). Surprisingly, when the link is clicked, mojarra calls hello.renderFragments
first and then hello.setCurrentPartial
, but MyFaces takes the opposite order, i.e., hello.setCurrentPartial
is called first.
So my question is whether there is a definition of the call order of action and ajax listener in JSF Spec. Which implementation is correct if the order is defined?
This attribute is used to call Java method by using an Ajax request. It is an attribute of <a:ajax> component. Here, we are creating an example that calls a method from ManagedBean. It includes the following files and code.
request() method of the JavaScript resource library collects the data provided by the f:ajax tag and posts the request to the JavaServer Faces lifecycle.
h. Tag commandLink. Render an HTML "a" anchor element that acts like a form submit button when clicked.
Ajax Attributes It is used to process in partial request. Immediate. false. boolean. It returns a boolean value that determines the phaseId, when true actions are processed at apply_request_values, when false at invoke_application phase.
As per the EG discussion, there's agreement on Mojarra behavior being correct as it's in line with how actionListener
/action
work. The MyFaces guy has created an issue on it and it's expected that this will be fixed for next MyFaces release. And, the JSF spec should be more explicit in this, this will be worked on.
In the meanwhile, if you want to have the same behavior in both Mojarra and MyFaces as to the method invocation order, move the <f:ajax listener>
to <h:commandLink actionListener>
.
<h:commandLink value="#{partial}" actionListener="#{hello.renderFragments}" action="#{hello.setCurrentPartial(partial)}">
<f:ajax render="include" />
</h:commandLink>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With