2017-07-21 3 views
0

je suit contrôle personnalisé:contrôle personnalisé à l'intérieur répétition ne peut pas voir rowData dans une propriété personnalisée, mais travailler dans d'autres

<?xml version="1.0" encoding="UTF-8"?> 
<xp:view xmlns:xp="http://www.ibm.com/xsp/core"> 
    <xp:this.beforePageLoad><![CDATA[#{javascript:compositeData.id = this.getId(); 
if (!compositeData.body_class) {compositeData.body_class='panel-body'}; 
if (!compositeData.panel_id) {compositeData.panel_id='section'+compositeData.id};}]]></xp:this.beforePageLoad> 
    <xp:panel> 
     <xp:this.styleClass><![CDATA[#{javascript:"ccSectionPanel panel " + compositeData.panel_class + ""}]]></xp:this.styleClass> 
      <xp:this.attrs> 
       <xp:attr name="id"> 
        <xp:this.value><![CDATA[#{javascript:compositeData.panel_id}]]></xp:this.value> 
       </xp:attr> 
      </xp:this.attrs> 
     <xp:panel styleClass="panel-heading" style="cursor:pointer;"> 
      <xp:this.attrs> 
       <xp:attr name="id"> 
        <xp:this.value><![CDATA[#{javascript:compositeData.panel_id + "_heading"}]]></xp:this.value> 
       </xp:attr> 
       <xp:attr name="href"> 
        <xp:this.value><![CDATA[#{javascript:"#" + compositeData.panel_id + "_section"}]]></xp:this.value> 
       </xp:attr> 
       <xp:attr name="data-toggle" value="collapse"></xp:attr> 
      </xp:this.attrs> 


      <xp:link escape="true" styleClass="panel-title" 
       text="#{javascript:compositeData.titleBarText}"> 
       <xp:this.attrs> 
        <xp:attr name="id"> 
         <xp:this.value><![CDATA[#{javascript:compositeData.panel_id + "_title"}]]></xp:this.value> 
        </xp:attr> 
       </xp:this.attrs> 
       <xp:this.id><![CDATA[${javascript:compositeData.panel_id + "_title"}]]></xp:this.id> 
      </xp:link> 
     </xp:panel> 

     <xp:panel> 
      <xp:this.styleClass><![CDATA[#{javascript:"panel-collapse collapse" + (compositeData.initClosed ? "" : " in")}]]></xp:this.styleClass> 
      <xp:this.attrs> 
       <xp:attr name="id"> 
        <xp:this.value><![CDATA[#{javascript:compositeData.panel_id + "_section"}]]></xp:this.value> 
       </xp:attr> 
      </xp:this.attrs> 
      <xp:panel 
       styleClass="#{javascript:compositeData.body_class}"> 
       <xp:callback facetName="panelBody" id="panelBody"></xp:callback> 
      </xp:panel> 
      <xp:panel rendered="#{javascript:compositeData.footer}" 
       styleClass="panel-footer"> 
       <xp:callback facetName="panelFooter" id="panelFooter"></xp:callback> 
      </xp:panel> 
     </xp:panel> 
    </xp:panel> 
</xp:view> 

Je l'utilise dans un contrôle de répétition:

<xp:repeat id="repeat1" rows="30" value="#{view1}" 
        var="repEntry" indexVar="index" repeatControls="false"> 
        <xp:panel> 
         <xp:this.data> 
          <xp:dominoDocument var="doc" 
           action="openDocument" 
           documentId="#{javascript:repEntry.getNoteID()}" 
           ignoreRequestParams="true"> 
          </xp:dominoDocument> 
         </xp:this.data> 
         <xc:ccSectionPanel initClosed="false" 
          panel_class="#{javascript:repEntry.getColumnValue('class')}" 
          footer="#{javascript:sessionScope.isAdmin}" 
          rendered="#{javascript:repEntry.getColumnValue('Status') == '1' || sessionScope.isAdmin}"> 
          <xc:this.titleBarText><![CDATA[#{javascript:repEntry.getColumnValue('Title') + (repEntry.getColumnValue('Status') != '1' ? ' (скрыто)' : '') 

}]]></xc:this.titleBarText> 
          <xp:this.facets> 
           <xp:panel xp:key="panelFooter"> 

            <xp:button value="Редактировать" 
             id="button2" styleClass="btn btn-xs"> 
             <i 
              class="glyphicon glyphicon-pencil"> 
             </i> 
             <xp:eventHandler event="onclick" 
              submit="true" refreshMode="complete"> 
              <xp:this.action> 
               <xp:openPage 
                name="/index.xsp" target="editDocument" 
                documentId="#{javascript:repEntry.getNoteID()}"> 
               </xp:openPage> 
              </xp:this.action> 
             </xp:eventHandler> 
            </xp:button> 
            <xp:button 
             value="#{javascript:repEntry.getColumnValue('Status') != '1' ? 'Показать' : 'Скрыть'}" 
             id="button3" styleClass="#{javascript:'btn btn-xs'}"> 
             <i 
              class="#{javascript:repEntry.getColumnValue('Status') != '1' ? 'glyphicon glyphicon-eye-open' : 'glyphicon glyphicon-eye-close'}"> 
             </i> 
             <xp:eventHandler event="onclick" 
              submit="true" refreshMode="partial" disableValidators="true" 
              refreshId="content"> 
              <xp:this.action><![CDATA[#{javascript:if (repEntry.getColumnValue('Status') == '1') { 
    doc.replaceItemValue('Status','0'); 
    doc.replaceItemValue('Author',sessionScope.User.UserName); 
    doc.save(); 
} else { 
    doc.replaceItemValue('Status','1'); 
    doc.replaceItemValue('Author',sessionScope.User.UserName); 
    doc.save(); 
}}]]></xp:this.action> 
             </xp:eventHandler> 
            </xp:button> 
            <xp:text escape="false" 
             id="computedField2" styleClass="btn btn-xs"> 
             <xp:this.value><![CDATA[#{javascript:'<i class="glyphicon glyphicon-user"></i>' + repEntry.getColumnValue('Author') + ' <i class="glyphicon glyphicon-time"></i>' + repEntry.getColumnValue('$1') 
}]]></xp:this.value> 
            </xp:text> 
           </xp:panel> 
           <xp:panel xp:key="panelBody"> 
            <!-- <xp:this.data> 
             <xp:dominoDocument var="doc" action="openDocument" 
             documentId="#{javascript:repEntry.getNoteID()}" 
             ignoreRequestParams="true"> 
             </xp:dominoDocument> 
             </xp:this.data> --> 
            <xp:inputRichText 
             id="inputRichText2" value="#{doc.Body}" readonly="true" 
             rendered="false"> 
            </xp:inputRichText> 
            <xp:text escape="false" 
             id="computedField1"> 
             <xp:this.value><![CDATA[#{javascript:doc.getDocument().getFirstItem("Body").getMIMEEntity().getContentAsText(); }]]></xp:this.value> 
            </xp:text> 


           </xp:panel> 
          </xp:this.facets> 
         </xc:ccSectionPanel> 
        </xp:panel> 
       </xp:repeat> 

Lorsque J'ai mis les propriétés cumputed, (picture) Cela fonctionne, mais quand je place panel_id à quelque chose par rapport à repEntry ou doc, il jette une erreur (repEntry est indéfini). Je peux définir "Créer des contrôles à la création de la page", mais ensuite je perds les avantages de l'actualisation partielle.

La question principale, pourquoi une propriété costom peut fonctionner avec repEntry, mais d'autres ne peuvent pas?

+0

Quel type de propriété est "panel_id"? Quelle valeur avez-vous définie à la propriété "panel_id"? –

+0

chaîne et chaîne. La question est pourquoi il ne peut pas utiliser la variable de ligne, mais un autre peut le faire. – Antiokh

+0

J'ai essayé de définir des valeurs: 1. repEntry.getPosition ('.'); 2. repEntry.getUniversalID(); 3. doc.getNoteId(); doc est indéfini, repEntry est indéfini – Antiokh

Répondre

0

La réponse se résume à quand la propriété est calculée. Calculez-le et ajoutez une instruction d'impression dans le code SSJS et vous verrez. Les ID doivent être calculés lorsque les composants sont chargés, donc dès la première partie du traitement. Et le plus important, c'est quand il génère un seul ensemble abstrait de composants, non associé à une entrée de ligne particulière, parce qu'il n'est pas encore construit la collection. Pensez-y comme si vous créiez une classe abstraite avant de créer des objets.

+0

L'instruction d'impression génère également une erreur – Antiokh

+1

Ce sera le cas si vous essayez d'imprimer quelque chose par rapport à la répétition. Si je ne peux pas déboguer et que je veux afficher l'ordre de traitement, j'utilise quelque chose comme 'print (" ID de calcul ");' Puis dans la répétition, ajoutez quelque chose comme 'print (" Chargement des valeurs de répétition "); Cela montrerait l'ordre de traitement et s'il essaye de calculer des ID avant qu'il ne réponde aux valeurs. Vous le verrez plus en détail dans ce webinaire sur les TLCC que j'ai livré https://www.youtube.com/watch?v=t7j_MR5uzCA&feature=youtu.be. –