XPages in Pictures - 06 - Creating Response Documents
Category XPages
This is the sixth article in the XPages in Pictures series.
At this point you have a small XPages application that allows you to track Company names and addresses. This app starts in a page that lets you view any companies that have already been created. There’s a “New Company” button to create additional companies. Inside the list of companies, you can click on the name of the company to open it up and edit it. Saving any changes brings you back to the Main page.
On a technical side, you’ve seen how to create an XPage and bind it to a form. You’ve seen how to add fields to the page and you’ve created a button that saved the data source and returned the user to a specific page. You’ve gone deep into the properties of the XPage and found and turned in “computeWithForm”.
Not too shabby really. Especially for so little coding so far. Once you go through this process the first time, the next time through should be much quicker.
Adding Contacts
Ok. Now’s the time to start integrating contacts into our application. The goal is to allow the user to enter as many contacts as they want for a particular company. They will open any company and see a “New Contact” button. They will also see a list of existing contacts on the company screen.
Let’s get started.
Create a new XPage and call it “xContact”.
Bind the page to the form “fContact”. Name the Domino Document “contactDoc”.
Now, just like you did for the company document, add all the fields from the Data panel to the page. Like, before, select them all and just drop them on the page. Rearrange the table order until it looks like this:
Now add a button to the page and change the label to be “Save”. Go to the onclick Mouse event and click on “Add Action”. Choose “Save Data Sources” and have the next page be xMain.
Note: Normally you would would not want to return to the xMain page on saving a contact. You’d prefer to return to the company that you were in. We’ll address this in a just a little bit.
Save your xContact page and open up the xCompany Page.
Drag a new button to the page. Call this “New Contact”. Like before, go to the onclick event and Add a Simple Action.
This time, you’re not going to use the “Basic” category. Click on the dropdown for Category and change it to “Document.” Change the Action to be “Create Response Document”. The name of the page to open is “xContact”.
The screen should look like this.
Notice that there’s a warning message. The Parent ID is required when creating response documents.
To give it a parent ID we’re going to use a little bit of JavaScript. Click on the diamond at the right of the Parent ID and choose “Compute value” to bring up the Script Editor.
The script editor should look like this:
The language we’re going to be using is JavaScript. Specifically Server Side Javascript; this gives you a lot of shortcuts.
If you think back to when we created an XPage and bound a document to it, the default name is usually “document1” and in the case of the “xCompany” page we changed that to “companyDoc”. Here is where you start to see this change getting used. Look carefully on the left hand side and you will see “companyDoc”. Expand “companyDoc” and take a look at the methods.
These methods are very similar to the backend objects that are used in LotusScript programming!
Double click on “getNoteID()” to add this to the script window.
That’s all you need. This will tell XPages to make this contact document a response document of the current company. The Parent ID is now computed. Your simple action screen looks like this:
Click ok to close the window and then make sure to save the XPage. Go ahead and create some contacts for different companies. Ignore the fact that on the save, we’re going back to the main page instead of the company page. That will get address shortly.
After creating some contacts you should then just verify that they are being created as response documents. In the Notes Client, open the view “vContacts” to check.
You’ve now seen how to create documents that are responses to the current document. We’ll be going deeper into this in the next few articles, working up to the equivalent of a show single category embedded view.
This is the sixth article in the XPages in Pictures series.
At this point you have a small XPages application that allows you to track Company names and addresses. This app starts in a page that lets you view any companies that have already been created. There’s a “New Company” button to create additional companies. Inside the list of companies, you can click on the name of the company to open it up and edit it. Saving any changes brings you back to the Main page.
On a technical side, you’ve seen how to create an XPage and bind it to a form. You’ve seen how to add fields to the page and you’ve created a button that saved the data source and returned the user to a specific page. You’ve gone deep into the properties of the XPage and found and turned in “computeWithForm”.
Not too shabby really. Especially for so little coding so far. Once you go through this process the first time, the next time through should be much quicker.
Adding Contacts
Ok. Now’s the time to start integrating contacts into our application. The goal is to allow the user to enter as many contacts as they want for a particular company. They will open any company and see a “New Contact” button. They will also see a list of existing contacts on the company screen.
Let’s get started.
Create a new XPage and call it “xContact”.
Bind the page to the form “fContact”. Name the Domino Document “contactDoc”.
Now, just like you did for the company document, add all the fields from the Data panel to the page. Like, before, select them all and just drop them on the page. Rearrange the table order until it looks like this:
Now add a button to the page and change the label to be “Save”. Go to the onclick Mouse event and click on “Add Action”. Choose “Save Data Sources” and have the next page be xMain.
Note: Normally you would would not want to return to the xMain page on saving a contact. You’d prefer to return to the company that you were in. We’ll address this in a just a little bit.
Save your xContact page and open up the xCompany Page.
Drag a new button to the page. Call this “New Contact”. Like before, go to the onclick event and Add a Simple Action.
This time, you’re not going to use the “Basic” category. Click on the dropdown for Category and change it to “Document.” Change the Action to be “Create Response Document”. The name of the page to open is “xContact”.
The screen should look like this.
Notice that there’s a warning message. The Parent ID is required when creating response documents.
To give it a parent ID we’re going to use a little bit of JavaScript. Click on the diamond at the right of the Parent ID and choose “Compute value” to bring up the Script Editor.
The script editor should look like this:
The language we’re going to be using is JavaScript. Specifically Server Side Javascript; this gives you a lot of shortcuts.
If you think back to when we created an XPage and bound a document to it, the default name is usually “document1” and in the case of the “xCompany” page we changed that to “companyDoc”. Here is where you start to see this change getting used. Look carefully on the left hand side and you will see “companyDoc”. Expand “companyDoc” and take a look at the methods.
These methods are very similar to the backend objects that are used in LotusScript programming!
Double click on “getNoteID()” to add this to the script window.
That’s all you need. This will tell XPages to make this contact document a response document of the current company. The Parent ID is now computed. Your simple action screen looks like this:
Click ok to close the window and then make sure to save the XPage. Go ahead and create some contacts for different companies. Ignore the fact that on the save, we’re going back to the main page instead of the company page. That will get address shortly.
After creating some contacts you should then just verify that they are being created as response documents. In the Notes Client, open the view “vContacts” to check.
You’ve now seen how to create documents that are responses to the current document. We’ll be going deeper into this in the next few articles, working up to the equivalent of a show single category embedded view.
- 


Comments
I learned alot of new stuff about xpages within a bit short of time..
Thnks alot..
Keep sharing al this to this world..
God bless U..
Posted by Pardeep At 04:36:32 AM On 02/26/2010 | - Website - |
Posted by Rimki At 06:45:21 AM On 05/24/2010 | - Website - |
Posted by Patrick Kwinten At 09:01:36 AM On 06/01/2010 | - Website - |