2017-07-21 33 views
0

工作,我有以下自定義控件:自定義控件無法看到rowData中一個自定義屬性,但在其他

<?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> 

我用它在一個重複控件:

<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> 

當我設置cumputed屬性, (picture) 它的工作原理,但是當我設置panel_id相對於repEntry或doc的東西,它會引發錯誤(repEntry是未定義的)。我可以設置「在頁面創建時創建控件」,但是我失去了部分刷新的優勢。

主要問題,爲什麼一個costom屬性可以使用repEntry,但其他不能?

+0

什麼屬性類型是「panel_id」?你將哪個值設置爲屬性「panel_id」? –

+0

字符串和字符串。問題是爲什麼它不能使用行變量,但其他人可以。 – Antiokh

+0

我嘗試設置值: 1. repEntry.getPosition('。'); 2. repEntry.getUniversalID(); 3. doc.getNoteId(); doc是未定義的,repEntry未定義 – Antiokh

回答

0

答案歸結到財產計算時。計算它並在SSJS代碼中添加一條打印語句,您會看到。在組件加載時需要計算ID,因此在處理的最早階段。最重要的是,這是它生成一個抽象的組件集合,而不是與特定的行條目相關聯,因爲它尚未構建集合。把它想象成在創建對象之前創建一個抽象類。

+0

打印語句也會引發錯誤 – Antiokh

+1

它會在您嘗試打印出與重複相關的內容時發生。如果我不能調試,並且想要顯示處理順序,我使用'print(「Computing ID」);'然後在重複中添加類似'print(「加載重複值」);'。這將顯示處理順序,以及它是否在迭代值之前嘗試計算ID。您將在本次發佈的https://www.youtube.com/watch?v=t7j_MR5uzCA&feature=youtu.be上的TLCC網絡研討會中看到更多細節。 –