2

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

Uwe J.
  • 315
  • 1
  • 8
  • I second Alex. Go revisit your questions and accept the answers – stwissel Dec 01 '14 at 10:40
  • 1
    Sorry for leaving things open - I now already have accepted (and upvoted) the answers which solves problems or are helpful. Answers which were not successfull are left open. Sorry if I still missed any – Uwe J. Dec 02 '14 at 15:21

1 Answers1

3

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.

Knut Herrmann
  • 30,880
  • 4
  • 31
  • 67
  • Hi Knut, this looks great (for me :-)! And it's already working with my buttons .... As far as I understood the event handler, it means that every click on any item will trigger my code? Kind Regards, Uwe – Uwe J. Nov 30 '14 at 20:45
  • Yes, every click on such a button executes the code in onItemClick event and there you have to figure out which button was clicked. – Knut Herrmann Nov 30 '14 at 21:08
  • Thx Knut - this works quite well :-) I hope this is not a performance eater, when every click is checked against a ssjs function. – Uwe J. Dec 02 '14 at 15:23