Not possible to place actions with SSJS in Action Bar of XPage OneUI?

266 Views Asked by At

I¨m working quite a while with XPages, and this must be a rookies question: I want to place my common actions like "Save Document", "Edit", "Cancel" in the Action Bar in the upper part of the OneUI of the extlib (Place Bar). I succeeded to get any basic (or other) nodes in the place bar, but I can only give them client side JS, not the usual server side JS which I gave to a button.

Am I missing sth? Of course I searched (here + google), but cannot find any answer for this simple question.

Hope you can "push me into the right direction" ....

thx, Uwe

1

There are 1 best solutions below

3
On BEST ANSWER

Add the buttons "Save" and "Edit" as xe:basicLeafNode to the action bar

<xe:applicationLayout ... >
    ...
        <xe:this.placeBarActions>
           <xe:basicLeafNode
              label="Save"
              submitValue="save">
           </xe:basicLeafNode>
           <xe:basicLeafNode
              label="Edit"
              submitValue="edit">
           </xe:basicLeafNode>

and define the code you want to execute as SSJS code in xe:applicationLayout's onItemClickevent

  <xp:eventHandler
     event="onItemClick"
     submit="true"
     refreshMode="complete">
     <xp:this.action><![CDATA[#{javascript:
            var s = context.getSubmittedValue();
            if (s=="save") {
                print("write code here for save");
            } else if (s=="edit") {
                print("write code here for edit");
            }
        }]]></xp:this.action>
    </xp:eventHandler>
</xe:applicationLayout>

You can test in onItemClick event with context.getSubmittedValue() for basicLeafNode's submitValue and get to know this way which button was clicked.