0

On an XPage I have a navigator that sets a sessionScope variabl based on the item selected. I was then using that value in a SwitchFacet to display one of several different views. And this worked well but I understand that the switchFacet loads the whole tree for all the views where as a dynamicContent control only load the tree for the selected panel. So I created a dynamicContent control inside a panelAll on the XPage (the Navigator does a partial refreesh of panelAll onClick) using the following code:

<xp:panel id="panelAll" style="width:auto">
  <xe:dynamicContent id="dynamicContent1">
    getComponent("dynamicContent1").show(sessionScope.get("ssSelectedView");
    <xp:this.facets>
      <xp:panel xp:key="vwProfile">
        <xc:ccProfileView></xc:ccProfileView>
      </xp:panel>
      <xp:panel xp:key="vwPending">
        <xc:ccTransactionView></xc:ccTransactionView>
      </xp:panel>
      <xp:panel xp:key="vwAgentLog">
        <xc:ccAgentView></xc:ccAgentView>
      </xp:panel>

    </xp:this.facets>
  </xe:dynamicContent>
</xp:panel>

The problem is that the views do not change like they do with the switchFacet. I know that the sessionScope variable id being set correctly and the onClick partial refresh should be refreshing the panelAll and picking a different panel to load but it only displays the vwProfile view. Is there something else I need to do to make the dynamic content work?

buzzsawddog
  • 662
  • 11
  • 32
Bill F
  • 2,057
  • 3
  • 18
  • 39

2 Answers2

1

dynamicContent controls unfortunately do not work with partial updates, only with a full reload of the page. I tried the same some months ago and it didn't work for me, too.

I used the workaround to put my pieces of "dynamic contect" in custom controls and use their rendered property to display them depending on the state of a sessionScope variable.

It's not perfect since the XPages engine always has all content of all custom controls in it's tree, but it's ok for medium complex applications.

Julian Buss
  • 1,114
  • 7
  • 14
  • I had the switchFacet working with this method but thought that I would move to the dynamicContent because it should be more efficient, but the full refresh doesn't seem to be a really efficient process either. Any thoughts on the performance difference between a switchFacet and rendered panels? – Bill F Oct 18 '13 at 15:09
  • I just built two medium complex applications, each with only one XPage and about 20-30 custom controls that are rendered depending on a sessionScope variable with partial update. Some of the controls contain notes views, other contain forms with a lot of tabs and so on. It's very fast and a very good experience for the user. – Julian Buss Oct 18 '13 at 17:04
  • I have the dynamic content working. I moved the getComponent().show into the onClick of the Navigator, then the partial refresh works. My onClick does this : getComponent("dynamicContent1").show(context.getSubmittedValue()); return sessionScope.put("ssSelectedView", context.getSubmittedValue()); – Bill F Oct 19 '13 at 00:47
1

You must call dynamicContent.show("yourFacetName"). This way it works for me. I am using partial refresh (and partial execution mode), but I am calling the .show() from inside the facets. I don't know if that makes the difference. Something like this:

<xe:dynamicContent id="dynamicContent1"
defaultFacet="read">
 <xp:this.facets>
  <xp:panel xp:key="read">
   <xp:link>
    <xp:eventHandler event="onclick"
submit="true" refreshMode="partial" refreshId="tableRow"
execMode="partial" execId="tableRow">
     <xp:this.action><![CDATA[#{javascript:var c = getComponent("dynamicContent1");
c.show("edit");}]]></xp:this.action>
    </xp:eventHandler>
   </xp:link>
  </xp:panel>
  <xp:panel xp:key="edit">
 </xp:this.facets>
</xe:dynamicContent>
Lauri Laanti
  • 948
  • 7
  • 11
  • Cool, I was not aware of that :-) – Julian Buss Oct 18 '13 at 06:50
  • I think that issue is that your onClick event is inside the dynamicControl because in my example I am calling the getComponent().show(sessionScope) inside the dynamicContent as well, but the partialrefresh is coming from outside (ie my Navigator). AS Julian has said it appears as if you need a full refresh to get the dynamicContent to refresh. – Bill F Oct 18 '13 at 15:37
  • So if the end user is not going to take any action inside this.facets I can't see how - in my case - how, I can use the dynamicContent. The switchFacet control, or using the rendered property on a number of custom controls works, but they both load the whole tree as I understand it so they are not really efficient from that perspective. BUT they work! – Bill F Oct 18 '13 at 15:38