Reputation: 11
I use ajax in my web page, then I remove it.
My code:
<h:commandButton type="submit" value="Test">
<f:ajax listener="#{connectionController.testConnect()}" execute="@form" render="msgCon"/>
</h:commandButton>
<h:commandButton id="btnCreate" type="submit" value="Create" action="#{connectionController.insertConnection(accountController.accLogin.id)}"/>
<h:commandLink styleClass="cmdLink" value="Cancel" onclick="clearConn()"/>
But when I run page again, generated code:
<input id="form:j_idt49" type="submit" name="form:j_idt49" value="Test" onclick="mojarra.ab(this,event,'action','@form','form:msgCon');return false">
<input id="form:btnCreate" type="submit" name="form:btnCreate" value="Create">
<a href="#" onclick="jsf.util.chain(this,event,'clearConn()','mojarra.jsfcljs(document.getElementById(\'form\'),{\'form:j_idt50\':\'form:j_idt50\'},\'\')');return false" class="cmdLink">Cancel</a>
Why does the cancel button still have ajax? How to fix it?
Upvotes: 0
Views: 283
Reputation: 1108642
That's not ajax. You're confusing "JavaScript" with "Ajax". You're probably also confusing the HTML representation of <h:commandButton>
with <h:commandLink>
. Those jsf.util.chain()
and mojarra.jsfcljs()
have got nothing to do with ajax. They just make it possible to submit a POST form using a plain link instead of a submit button. In plain HTML it's not possible to submit a POST form using a plain link. That's why those helper scripts are all there.
To experiment further, add <f:ajax>
inside the <h:commandLink>
. You'll see that it get a mojarra.ab()
function call in the generated HTML. This will in turn indeed use ajax. Or, replace <h:commandLink>
by <h:commandButton>
. You'll see that there are no helper scripts anymore to submit a form using a plain link.
Upvotes: 2