title: XPages - How do I specify 'selectedTab' for a repeated Dojo Accordion control
body: <p>I am trying to preserve the last selected state of a dynamic accordion control by storing the selectedTab ID in a sessionScope variable and then specifying this value as the 'selectedTab' parameter for the Accordion Container when the control loads/refreshes rather than defaulting to the first tab.</p>
  
  <p>The code below is a simple XPage that demonstrates where I currently am, it stores the ID of the selected Accordion Tab but continues to default to the first Tab on refresh.....could someone please point out where I'm going wrong. </p>
  
  <p>'Create controls at page creation' is checked (true)</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;xp:view xmlns:xp="http://www.ibm.com/xsp/core"
  xmlns:xe="http://www.ibm.com/xsp/coreex"
  xmlns:debug="http://www.openntf.org/xsp/debugtoolbar"&gt;
  &lt;xp:this.beforePageLoad&gt;&lt;![CDATA[#{javascript:sessionScope.tabLabels = ["Tab1","Tab 2","Tab 3"];
  
  if (!sessionScope.containsKey("openTab")){sessionScope.openTab = ""};
  }]]&gt;&lt;/xp:this.beforePageLoad&gt;
  &lt;xe:djAccordionContainer id="djAccordionContainer1"
      selectedTab="#{javascript:sessionScope.openTab}"&gt;
  &lt;xp:repeat id="repeat1" rows="30" value="#{sessionScope.tabLabels}"
      var="tabs" indexVar="tabIndex" repeatControls="true"&gt;
      &lt;xe:djAccordionPane style="font-weight:bold"
          title="#{javascript:tabs}"&gt;
          &lt;xe:this.id&gt;&lt;![CDATA[${javascript:"djAccordionPane" + tabIndex}]]&gt;
  &lt;/xe:this.id&gt;
          &lt;xp:label value="Label" id="label7"&gt;&lt;/xp:label&gt;
          &lt;xp:br&gt;&lt;/xp:br&gt;
          &lt;xp:label value="Label" id="label8"&gt;&lt;/xp:label&gt;
          &lt;xp:br&gt;&lt;/xp:br&gt;
          &lt;xp:label value="Label" id="label9"&gt;&lt;/xp:label&gt;
          &lt;xp:eventHandler event="onShow" submit="true"
              refreshMode="complete"&gt;             
  &lt;xe:this.action&gt;&lt;![CDATA[#{javascript:sessionScope.openTab =  
  this.getParent().getId();}]]&gt;&lt;/xe:this.action&gt;
          &lt;/xp:eventHandler&gt;
      &lt;/xe:djAccordionPane&gt;
  &lt;/xp:repeat&gt;    
  &lt;xe:this.dojoAttributes&gt;
          &lt;xp:dojoAttribute name="doLayout" value="false"&gt;&lt;/xp:dojoAttribute&gt;
      &lt;/xe:this.dojoAttributes&gt;
  &lt;/xe:djAccordionContainer&gt;
  &lt;xp:span style="font-weight:bold"&gt;&lt;/xp:span&gt;
  &lt;/xp:view&gt;
  </code></pre>