I have a toolbar with two basicLeafNodes in which I need to call some CSJS when they are clicked. To do this I put the CSJS in the onClick event of the basicLeafNode but when I do this, regardless of whether I return true, false or no return at all, the eventHandler for event="onItemClick" does not execute. If I remove the CSJS in the onClick event then onItemClick executes. Any ideas on what I am doing wrong here?
<xe:toolbar>
<xe:this.treeNodes>
<xe:basicLeafNode label="Back" submitValue="Back"></xe:basicLeafNode>
<xe:basicLeafNode label="Save & Back" submitValue="SaveAndBack" loaded="${javascript:document1.isEditable()}" onClick="console.log('save and back clicked');"></xe:basicLeafNode>
<xe:basicLeafNode label="Edit" submitValue="Edit" loaded="${javascript:!(document1.isEditable())}"></xe:basicLeafNode>
<xe:basicLeafNode label="Save" submitValue="Save" loaded="${javascript:document1.isEditable()}" onClick="console.log('save clicked'); return true;"></xe:basicLeafNode>
<xe:basicLeafNode label="Delete"></xe:basicLeafNode>
</xe:this.treeNodes>
<xp:eventHandler event="onItemClick" submit="true" refreshMode="partial" refreshId="dc" disableValidators="#{javascript:context.getSubmittedValue() == 'Back'}">
<xe:this.action>
<![CDATA[#{javascript:
vendor.runAction(context.getSubmittedValue(), document1);
}]]></xe:this.action>
</xp:eventHandler>
</xe:toolbar>
basicLeafNode
's onClick event overwritestoolbar
's onItemClick event.This is visible in rendered page source.
Just turn it around: add your client side actions into
toolbar
's onItemClick event.You can get the clicked label with
and add your code depending on clicked label.
Here is a working XPage example: