如何在重复控制中在线编辑的文档中保存值

时间:2014-07-09 23:39:57

标签: xpages repeat inline-editing

我对xPage进行了重复控制,文本字段直接以编辑模式显示。当用户更改字段中的值时,我需要它们能够:

  1. 选择字段旁边的图标,将值保存在文档中。
  2. 在多个文档中对此字段进行更改,然后单击按钮将所有这些更改保存到同时保存的相应文档中。
  3. 到目前为止,我所掌握的是一种捕获其可编辑字段已更新的文档的unid的方法。

    我无法让这些保存工作。我在下面列出了控制这些区域的代码部分。

    以下是save all和sessionScope信息

    <xp:panel id="InlineEditContainer" xp:key="facetMiddle" style="width:100%">
    <xp:this.data>
    <xp:dominoView var="view1" viewName="vwMetricsByAssigned">
    <xp:this.postOpenView><![CDATA[#{javascript:var myList = new java.util.ArrayList();
    sessionScope.put("myList", myList);}]]></xp:this.postOpenView></xp:dominoView>
    </xp:this.data>
    <xp:button value="Submit All" id="button1">
    <xp:eventHandler event= <"onclick" submit="true" refreshMode="complete">
    <xp:this.action><![CDATA[#{javascript:// Getting list of unids from docs which have been        updated, and saving those docs
    var db:NotesDatabase
    
    if(sessionScope.myList == null){
    return;
    }else{
    for (var s in sessionScope.myList){
        var doc:NotesDocument = (db ? db.getDocumentByUNID(s) : database.getDocumentByUNID(s));
        if (doc && doc.isValid()) { 
            doc.save();
        }
    }
    }}]]></xp:this.action>
                    </xp:eventHandler>
                </xp:button>
                <xp:br></xp:br>
    <xp:repeat id="repeat1" rows="30" value="#{sessionScope.myList}" var="listData">        
        <xp:text escape="true" id="computedField6"><xp:this.value><![CDATA[#{javascript:listData +    " , "}]]></xp:this.value></xp:text></xp:repeat>
    
    <xp:br></xp:br>
    

    以下是所有重复数据

    <xp:repeat id="repeat2" rows="20" var="FColl" indexVar="idx" value="#{javascript:view1}">
    <xp:panel id="InlineEditContainer2">
    <xp:this.data>
    <xp:dominoDocument var="document1" formName="frmMetricData"                                  action="editDocument" documentId="#    {javascript:FColl.getNoteID();}" >
    </xp:dominoDocument>
    </xp:this.data>
    <xp:tr>
    <xp:td id="td1">
    
    <xp:text escape="true" id="computedField3">
    <xp:this.value>    <![CDATA[#javascript:FColl.getDocument().getItemValueString("BusinessUnit")}]]>   
    </xp:this.value>
    </xp:text>
    </xp:td>
    <xp:td id="td2">
    <xp:link escape="true" id="link1" value="/MetricData.xsp">
    <xp:this.text><![CDATA[#{javascript:FColl.getDocument().getItemValueString("MetricName")}]]>  </xp:this.text>
    <xp:eventHandler event="onclick" submit="true"                                            refreshMode="norefresh" immediate="true">
    <xp:this.action>
    <xp:openPage name="/MetricData.xsp" target="editDocument"                              documentId="#{javascript:return FColl.getNoteID();}" />
    </xp:this.action></xp:eventHandler>
    </xp:link>
    </xp:td>
    <xp:td id="td3">
    <xp:inputText id="EditBox3" value="#{document1.Actual}" tabindex="1">
    <xp:this.defaultValue><![CDATA[#    {javascript:FColl.getDocument().getItemValueString("Actual")}]]></xp:this.defaultValue>
    <xp:this.converter>
    <xp:convertNumber type="number" integerOnly="true" />
    </xp:this.converter>
    <xp:eventHandler event="onchange" submit="true" refreshMode="partial" refreshId="repeat1">
    <xp:this.action><![CDATA[#{javascript:// get the universalID of the document
    var keyCode = FColl.getDocument().getUniversalID();
    
    // Create an Array
    var myArray = sessionScope.get("myList");
    
    //If it's not already in the Array then add it.
    if (!myArray.contains(keyCode)) {
    myArray.add(keyCode);
    }}]]></xp:this.action>
    </xp:eventHandler></xp:inputText>
    <xp:span>
    <xp:image url="/.ibmxspres/domino/oneuiv2/images/iconConfirmation16.png" id="image1">
    <xp:eventHandler event="onclick" submit="true"                                               refreshMode="complete">
    <xp:this.action>
    <xp:saveDocument var="document1" />
    </xp:this.action>
    </xp:eventHandler>
    </xp:image>
    </xp:span>
    

    如果有人能给我任何想法,我会非常感激。

1 个答案:

答案 0 :(得分:1)

简单点!有一个简单的动作“保存”。进来保存并保存所有口味。后者在重复之下,保存任何已更改的文档。