The Problem is that you only have the clientSide onClick. You can call a SSJS EventHanlder from the ClientSide like discripted by Jeremy Hodge.
For this example i used the full executeOnServer script from Jeremy but i think you could alter it a bit. I also used a full refresh you could also use a partial refresh if you dont want to refresh the complete page.
<xe:toolbar
id="toolbar2">
<xe:this.treeNodes>
<xe:basicLeafNode
href="whereToGo.xsp"
label="Save and close"
onClick="executeOnServer('saveDocument');">
</xe:basicLeafNode>
</xe:this.treeNodes>
</xe:toolbar>
<xp:scriptBlock>
<xp:this.value><![CDATA[
var executeOnServer = function () {
if (!arguments[0])
return false;
var functionName = arguments[0];
var refreshId = (arguments[1]) ? arguments[1] : "@none";
var form = (arguments[1]) ? XSP.findForm(arguments[1]) : dojo.query('form')[0];
var options = (arguments[2]) ? arguments[2] : {};
dojo.query('[name="$$xspsubmitid"]')[0].value = form.id + ':' + functionName;
XSP._partialRefresh("post", form, refreshId, options);
}
]]></xp:this.value>
</xp:scriptBlock>
<xp:eventHandler event="saveDocument" submit="false"
id="saveDocument">
<xp:this.action>
<xp:actionGroup>
<xp:executeScript>
<xp:this.script><![CDATA[#{javascript:println("save")}]]></xp:this.script>
</xp:executeScript>
<xp:save></xp:save>
</xp:actionGroup>
</xp:this.action>
</xp:eventHandler>
Another way would be (as Oliver already mentioned) to use a real button placed in an hidden div.