I want to make switchFacet for practice, but in vain. Actually dont know where to start. Can this be written only in java? Here is my code. I try to pass variable through sessionScope. Button updates value, but facet doesnt. Facet changes value if I click URL and then ENTER.
This is my Xpage:
<xc:FacetContainerCC viewPanelTest="#{sessionScope.VarTest}">
<xp:this.facets>
<xp:div xp:key="SecondCC"><xc:SecondCC></xc:SecondCC></xp:div>
<xp:div xp:key="FirstCC"><xc:FirstCC></xc:FirstCC></xp:div>
</xp:this.facets>
<xp:button value="#{javascript:sessionScope.VarTest}" id="button1">
<xp:eventHandler event="onclick" submit="true" refreshMode="complete">
<xp:this.action><![CDATA[#{javascript:if (sessionScope.get("VarTest") == "First")
sessionScope.put("VarTest", "Second"); else sessionScope.put("VarTest","First");}]]>
</xp:this.action>
</xp:eventHandler>
And my facet:
<xp:callback id="callback1">
<xp:this.facetName><![CDATA[#{javascript:
var viewPanelTest = sessionScope.get("VarTest");
if (viewPanelTest == "First") return "FirstCC";
else return "SecondCC";}]]>
</xp:this.facetName>
I noticed there is a difference between updating page by button and re-entering URL. Button makes POST request, re-entering URL makes GET request. FirstCC and SecondCC are custom components dropped on facet. And... sessionScope variables with same name co-exists on client and server, right?