Вопрос

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?

Это было полезно?

Решение

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.

Другие советы

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>
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top