Creating an XPage for a main documentAdded by IBM on September 28, 2011 | Version 1 (Original)
|Your XPages application uses the Domino® data store. The way to get at the Domino data store without programming is through forms.
Your XPages application uses the Domino
® data store. The way to get at the Domino
data store without programming is through forms.
For this application, use the existing main
form you created earlier.
form contains fields for subject
, and category
. Your new XPage will specify the main
form as its data source and bind its input controls to the subject
, and category
Parent topic: Your first XPages application
- In the Application Navigator, right-click on XPages and select New XPage.
- Name the XPage main but DO NOT immediately click OK.
For simplicity of design, you are naming the XPage after its data source.
- Select the Add data source to the page option in the New XPage dialog.
- From the Data Source drop-down list, select Domino Document for the data source.
- From the Form drop-down list, select main.
- Click OK.
There are other ways to add data sources to an XPage if you don't do it at page creation.
- The next task is to add controls that are bound to the data source:
- On the right, open the Data palette.
If the tab is not there, click Window -> Show Eclipse Views -> Data. Your document1 data source should be visible.
- Ensure that Select Controls dialog box (the icon above the words Data source) is enabled.
Hovering over the icon shows you the current state. Click on the box to enable the setting if it is currently disabled.
- Select all the items in the data source.
- Drag the selected items to the edit area.
- In the dialog that opens, change the Control type for Category from Edit Box to Combo Box, and select Add Submit button to generated code.
- Click OK.
This process provides a quick way to create a table with labels, input controls, and a button. The controls are bound to the items in the Domino
data source. You can see this by putting focus on an edit box then clicking the Data
tab under properties.
You do not have to set up your XPage this way. You can drag and bind controls individually.
- Adjust the category control to provide choices and a default value:
- Put focus on the category control.
- Under properties, click the Data tab and enter red for the default value.
- Click the Values tab and use the Add Item button to add labels and values for red, green, and blue.
- The Submit button is a special button that sends data placed on the XPage to the data source. Having a Cancel button is also useful:
- On the right, click on the Controls tab.
- Drag a Button control into the edit area alongside the Submit button.
- Under properties, change the label to Cancel.
- To the right, change the button type to Cancel.
- Tie this page into the first XPage to form a cohesive application:
- Put focus outside all controls so that the properties for the page appear in the bottom pane.
- For Next Page, select mainview.
This means that after the Domino
server processes a submit or cancel request from the main
XPage, it will open the mainview
- Save the main XPage.
- Next adjust the mainview XPage:
- Open the mainview XPage and put focus at the very beginning - before the View control.
- On the Controls palette, double-click the Button control.
The new button should appear at the top of the XPage.
- Under properties, change the label of the new button to New document.
- Directly below the edit area, click the Events tab.
- Click Add Action.
A dialog opens. Ensure that the action is Open Page.
- For the page to open, select main.
- For target document, select New document.
- Click OK and save the XPage.
- Preview the mainview XPage or open the application in Notes® or a browser:
- Click the New document button.
This opens main.
- Fill in the edit boxes and click the Submit button.
This creates a document and takes you back to mainview.
- You might also try the Cancel button.