XPages: SOLVED - dynamically loading CustomControl? Or getting its name via compositeData?

I’d like to dynamically load the appropriate custom control on an XPage at runtime. The name of the custom control is stored in a field on the document/datasource associated with the XPage. In beforePageLoad I’m storing the custom control name in a viewScope variable. Now, I’ve done a few things that work, but wonder if there’s a better way.

I’ve dragged all of the potential custom controls into the XPage. (I’d prefer not to even have to do that …)

In beforePageLoad I can setRendered = true on the appropriate custom control by getting a handle to all of their IDs.

var xPageCCVal = currentDocument.getItemValueString(“XPageCC”);

viewScope.whichCC = xpageCCVal;

var reviewGenericCC:javax.faces.component.UIComponent = getComponent(“ccGenericReview”);

var reviewProjLeaderCC:javax.faces.component.UIComponent = getComponent(“ccProjLeaderReview”);

if (xPageCCVal == “ccProductStep1Review_Generic”)

reviewGenericCC.setRendered(true); 

else

reviewGenericCC.setRendered(false); 

if (xPageCCVal == “ccProductStep1Review_ProjLeader”)

reviewProjLeaderCC.setRendered(true); 

else

reviewProjLeaderCC.setRendered(false);

Not fussy about this solution, but it does work.

In the rendered property of each custom control I can check if the viewScope variable value = the hard-coded value of the custom control name.

return viewScope.whichCC == “ccProductStep1Review_ProjLeader”;

OK, works, but not great.

Ideally, I’d like to not have to hard-code the custom control names. I suppose I could add a Property (eg. myName) to each custom control where I could then type in the name of the custom control then change my rendered property to:

return viewScope.whichCC == compositeData.myName;

but that’s not much better than my 2nd solution.

Is there a compositeData. that’ll give me the name of the custom control itself? Or, another way I can get the name of the custom control programmatically?

OR, I did try to just create a computed field displayed as HTML & include the viewScope variable in “xc:” “</xc:>” tags but that didn’t work. That would be my ultimate solution to dynamically bring in the custom control I need … am I dreamin’ or what!