The primary focus of this Wiki article is to touch upon the use of Simple Actions from an event in an XPage. Simple Actions are provided as a means to perform several simple operations without having to do any coding. Domino Designer v8.5 provides 11 simple actions to assist you in performing common operations
It seems that the easiest way to explain Simple Actions is to dive in with an example. In Figure 1, we create 2 XPages named CLXpage and MLXpage to do some work. We opened the CLXPage in an editor. We dragged a Button onto that XPage and named it "Push Me". We selected the Events Tab. The "onclick" event is selected by default.
Pressing the "Add Action..." button (circled above) takes us to Figure 2, the Add Simple Action dialog.
: Add Simple Action Dialog
The Add Simple Action Dialog defaults to the "Basic" Category and the "Open Page" Action. (More on Categories and Actions later.)
Selecting the combo box next to "Name of page to open:" should bring us to Figure 3.
: Add Simple Action Dialog - Basic - Open Page - Name
Here we see that the XPages that exist in our application are displayed. Since we are working on the CLXPage, we will pick the MLXpage as the page to open.
The error text at the top will display as soon as the combo box is selected and will disappear once a name is selected.
Let's move to the next field "Target Document" shown in Figure 4.
: Add Simple Action Dialog - Basic - Open Page - Target
We are presented with three choices: New document, Open Document and Edit Document. Let's choose leave it empty.
We can do this because leaving those options empty lets the page execute what is defined in its datasource.
Note: The choices (openDocument...) only make sense if the target page is accessing a document.
That will take us to the Document ID field in Figure 5.
: Add Simple Action Dialog - Basic - Open Page - Diamond
You may have noticed the diamond icons next to the all three of the fields. If you selected a diamond, you get the menu shown. This allows for more complex values than the simple values presented for these fields. If we select "Compute Value" here, we get an editor where we can indeed compute a complex value for the Document ID. We'll chose to do neither and leave the value empty. The complete dialog is displayed in Figure 6.
: Add Simple Action Dialog - Basic - Open Page - Document ID
Before we press " OK", let's go back and look at the context, not just the dialog. Figure 7 shows us the screen with our XPage and the Add Simple Action dialog.
: Add Simple Action Dialog - completed
Pressing OK at this time will add the Simple Action to the onclick event of the "Push Me" button. In Figure 8, you can see where an Open Page action has been added to the Simple Actions Root of the onclick event.
: CLXPage with 1 Simple Action
Clicking on the Source tab of the XPage shows the code added for you to handle the onclick of the "Push Me" button. This is shown in Figure 9.
: CLXPage source
So, this simple action has been added. Now, at runtime, clicking the "Press Me" button will open the MLXpage.
Of course, we could have added this Simple Action to any other event in the Mouse, Focus or Key events. This would be a good time to explore those other events to see what we make available to you. Figure 10 shows the available Mouse, Focus and Key events for a Button control. Other controls event lists may vary.
: Events list for a Button Control
Other Basic Simple Actions
Thus far, we have only looked at the Basic - Open Page Simple Action. There are, of course, other Simple Actions.
Figures 11, 12 and 13 show the other Actions in the Basic Category.
: Add Simple Action Dialog - Basic - Confirm Action
Confirm Action is a special Simple Action. Simple Actions are located on the Server tab for a reason. These actions take place on the Server.
The "Confirm Action" Simple Action generates client code to execute when the event occurs, before sending the data to the server. Keep this in mind, we'll come back to it later.
: Add Simple Action Dialog - Basic - Execute Script
Use this Action to insert script in the middle of other action. If you only need to execute script, it is better to use the script option for the event.
: Add Simple Action Dialog - Basic - Save Data Sources
Multiple Simple Actions
What if we wanted to add more that one Simple Action to an Event? That is not a problem. I've added a Basic Confirm Action to the onclick event.
You can see the results in Figure 14. An "Action Group" in inserted and the "Confirm Action" is added to the list. You will note that the up and down arrows can now be used to order the Simple Actions in side the Action Group. Remember the special notice on the Confirm Action (back in Figure 11)? As the Confirm Action is executed on the client, it is executed first, no matter where it appears in this list.
The Action Group can be edited to add conditions for when it fires, or can just be left as is.
: CLXPage with 2 Actions
If you change the Category to "All" in the Add Simple Action dialog, you will see all the available Simple Actions. The list of all Actions is seen in Figure 15. We encourage you to scroll through the various actions to see what they do and what fields that act upon. This could make your XPage event handling somewhat easier.
: Add Simple Action Dialog - All options
After reading this article you should be able to locate and use the Simple Actions dialog for an Xpage. This article has only touched on the basics. There is a lot more to explore. You should have the basic tools to explore the rest of the Simple Actions and see how they combine in your Xpage.