XPages in Pictures - 9 - Show Single Category
Category XPages
The next feature to add to the application is a way to display all contacts from the current company page. The key difference here is that you want to filter the contacts to only show the contacts for the particular company that you’re currently viewing. There are some new ways to do this in Xpages, like a repeat control, but here I’m going to use a view control again. This will work just like the Notes client when a view is embedded on a form set to show single category.
Open the xCompany Page in Designer. Add a Carriage Return at the bottom of the page to give you some space and then find the View control in the Container Controls panel and drag it to the page. In the box that appears choose “vContacts” as the Data Source. Leave all the columns selected and click on OK.
Now, if you preview this changes, you’ll see the complete “vContacts” view on your page. Now you need to filter it. To filter, you’re going to use the scoped variable “companyCode” that was created in the afterPageLoad event of the “xCompany” page.
To retrieve the Session Scope Variable use the get method:
sessionScope.get(variableName)
If you were working with a viewScope then it would be:
viewScope.get(variableName)
So to retrieve the companyCode variable, the syntact will be?:
sessionScope.get(“companyCode”)
The trick is going to be finding where to put this.
Select the entire view control on your page. This is done by clicking on the outside box until it looks like:
Now, in the properties tab, click on “All Properties and drill down to data\data and find categoryFilter. Remember that even though this is a simple statement, you can not just type it in the box. You would only do that for hard coded values. Click on the diamond to the right and choose “Compute Value”. In the script editor that appears enter your code:
sessionScope.get(“companyCode”)
Click ok and you should see this:
Save the page. And open your application starting with the “xMain” page and open a company. You should now see only the contacts for the company you choose.
The next feature to add to the application is a way to display all contacts from the current company page. The key difference here is that you want to filter the contacts to only show the contacts for the particular company that you’re currently viewing. There are some new ways to do this in Xpages, like a repeat control, but here I’m going to use a view control again. This will work just like the Notes client when a view is embedded on a form set to show single category.
Open the xCompany Page in Designer. Add a Carriage Return at the bottom of the page to give you some space and then find the View control in the Container Controls panel and drag it to the page. In the box that appears choose “vContacts” as the Data Source. Leave all the columns selected and click on OK.
Now, if you preview this changes, you’ll see the complete “vContacts” view on your page. Now you need to filter it. To filter, you’re going to use the scoped variable “companyCode” that was created in the afterPageLoad event of the “xCompany” page.
To retrieve the Session Scope Variable use the get method:
sessionScope.get(variableName)
If you were working with a viewScope then it would be:
viewScope.get(variableName)
So to retrieve the companyCode variable, the syntact will be?:
sessionScope.get(“companyCode”)
The trick is going to be finding where to put this.
Select the entire view control on your page. This is done by clicking on the outside box until it looks like:
Now, in the properties tab, click on “All Properties and drill down to data\data and find categoryFilter. Remember that even though this is a simple statement, you can not just type it in the box. You would only do that for hard coded values. Click on the diamond to the right and choose “Compute Value”. In the script editor that appears enter your code:
sessionScope.get(“companyCode”)
Click ok and you should see this:
Save the page. And open your application starting with the “xMain” page and open a company. You should now see only the contacts for the company you choose.
- 


Comments
Posted by Rafal At 08:22:04 AM On 10/08/2009 | - Website - |
"... use the scoped variable “companyCode” that was created in the afterPageLoad event of the “xCompany” page. "
Posted by Andrew At 11:38:34 AM On 01/28/2010 | - Website - |
Great series - really enjoying reading it and trying to soak it all in
One question if I may - if I wanted to put a ViewPanel within a Repeat control and filter each ViewPanel by the "collection name" of the Repeat, how would I do that? At what point to I set the scope variable as I can;t seem to reference the entry in the Repeat control
Many thanks
Mike
Posted by Mike At 07:52:41 AM On 02/15/2010 | - Website - |
expecting more like this..
please updates when new series comes...
Thanks alot..
Posted by Pardeep At 06:22:57 AM On 02/26/2010 | - Website - |
Thanks again
Dan
Posted by Dan At 03:12:14 PM On 04/21/2010 | - Website - |
Hope to see additional posts soon!
Posted by Gary At 02:00:31 PM On 05/20/2010 | - Website - |
Posted by Jared At 11:09:36 AM On 05/25/2010 | - Website - |
Thanks
Posted by Staale At 10:35:32 AM On 06/23/2010 | - Website - |