Dynamic Content notes
Nov 20, 2013
I've fallen in love with the Dynamic Content control. It may have taken me a bit to get on board, but now that I am, I'm really liking it. I thought I'd post a few things on Dynamic Content Controls for anyone starting on them.
First, you can get the name of the facet currently "active" very easily by call in the "getCurrentFacet()" property. So if you but the below in a computed field, it will tell you what facet you have showing:

var c=getComponent("dynamicContent1");

var facetName:String = c.getCurrentFacet();
return facetName +  "<<<";
This makes it a bit easier to set things up so you can navigate around in a complex manner (if x and y, then a, otherwise b - you know how that goes).
Second, it is important to give unique names to your Dynamic Content controls. In my second use, I created a Dynamic Control called "DynC", which is what it's called in the example I was using. Well, I was also in a nsf someone else had created, so my control was nested inside of theirs. I think they used the same example, because they called their dynamic control "DynC" as well Grin  So I tried mine, Notes tried to change their control to a facet that existed only in mine. It didn't work. That makes sense, since Domino started at the "top" of the tree and went looking for a control named "DynC". It found it then tried to change the facet. Since our name duplication stopped at the control, there wasn't a facet by that name. When I changed my name to "innerDynC", everything worked. 
Third, so after the adventure I had that gave me the second point, I started making sure my dynamic controls had unique  names. Then I came up another issue. I a couple custom controls that I wanted to be in the facets of different custom controls. There is a mantra that keeps going around the back of my head about XPages "Almost everything is computable". And sure enough, you can compute what dynamic control and facet you are working on. So if I put in what dynamic control and what facet I started from, I can get back there. Here is a little sample:


var c  = getComponent(sessionScope.DyncElement);
In this case, my dynamic control is called "OfficerRecordDCon". I put that in the scoped variable "DyncElement", so I know what dynamic control I am working with. Since I needed to know where to send the user "back" to, I also put in the facet I'm starting from. In this case, it's "officerAllview" (that's the facet name). Works the same if you use the simple action, just hit the diamond to compute with your scoped variables.
Then I get the dynamic content control as a variable and then trigger what facet I want to show. Refreshing a page/panel or whatever takes care of the change. 
I also made a discovery I want to look further into, but I thought I'd share nevertheless. I was working on an XPage app where responses to some questions caused new fields to appear or not. I was getting some replication/save conflicts on the backend Domino document. Originally I had made this as a "standard" XPage. But no matter what I did, I was getting RSCs or losing data. So I put everything into a Dynamic Control and things started working properly. I was using a table to control spacing, and with some events, I had to refresh the entire table, which was effectively the entire page. I would get RSCs or lose data or my validation wouldn't fire properly. Once in a dynamic control, things worked as expected (wanted). I could do a partial refresh on the entire table and the new fields would appear like they should, no RSCs, no lost data, and my validation worked. I don't have an explanation as to why, but it was a blessing that it worked that way. 
This is an archive of my previous blog http://www.bleedyellow.com/blogs/DominoHerald attachments are in the download control