« Notes in Nine - 004 - Can't we all get along with our Scoped Variables | Main| IamLUG or Bust. (Hopefully not bust) »

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.


A picture named M2


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:

A picture named M3

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:
A picture named M4

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.

A picture named M5


Comments

Gravatar Image1 - First tutorial which helped me to get running my 1st xpage. Thanks a lot.

Gravatar Image2 - Great up to...
"... use the scoped variable “companyCode” that was created in the afterPageLoad event of the “xCompany” page. "


Gravatar Image3 - David,

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

Gravatar Image4 - Lots of learning...

expecting more like this..

please updates when new series comes...

Thanks alot..

Gravatar Image5 - Thanks so much for your clear explanation. Easy enough for someone not even that comfortable with "traditional" notes programming to understand.

Thanks again

Dan

Gravatar Image6 - Thanks for a great and easy to understand example that works. The only small problem is on the last page: sessionScope.get(“companyCode”). If you are like me and take the short cut of copying and pasting, the the quote marks are not correct. Just add standard "" marks and it works great!

Hope to see additional posts soon!Emoticon

Gravatar Image7 - In the article you mention being able "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...". This is exactly what I'm trying to do, without a view control or a data table. How do you add a category filter to a repeat control? 'All properties' for a repeat control does not include a categoryFilter property.

Gravatar Image8 - I'm not able to make this work for a dateview. I have certain contracts which are sorted categorized by date and the categoryfilter functionality is not working for that. I works very well when I'm not using dates.. Do you have any comments on why dates should not work?
Thanks

Post A Comment

:-D:-o:-p:-x:-(:-):-\:angry::cool::cry::emb::grin::huh::laugh::lips::rolleyes:;-)

Powered By:

Domino BlogSphere
Version 3.0.2