Here is how we are doing this:
Our button looks like this:
<h:commandButton id="id" onclick="doSomething()" />
Our JavaScript looks like this:
function doSomething()
{
// Do some javascript stuff here
//...
// get reference to our hidden command link to fire a backing bean method
var hiddenCommandLink = window.document.getElementById("pageForm:cl1");
if (hiddenCommandLink )
{
hiddenCommandLink .fireEvent("onclick");
}
}
Our hidden commandLink that calls the backing bean method looks like this:
<h:commandLink action="#{backingBean.doSomething}" id="cl1" style="display: none" />