我有一个重复控件,其源代码为notesdocumentcollection。在重复控件内部,我有一个具有数据源的面板,数据源的文档id属性设置为单个文档的通用id,在我的例子中是重复控制变量apprDoc(apprDoc.getUniversalID)。因此,使用面板数据源,我试图将重复控件中的每个字段直接绑定到相应的后端文档。我点击了一个提交按钮,我需要将用户选择的值发布到后端文档中,并设置一些其他未绑定到后端文档的字段。我需要获取文档集合中每个文档的句柄,以便在后端文档上设置字段值。有人可以建议一种方法来做同样的事情,或任何其他方式来实现我想要实现的功能。请在下面找到相同的代码:
<xp:repeat id="repeat1" rows="30" var="apprDoc" indexVar="docIndex"
first="0">
<xp:this.value><![CDATA[#{javascript:// Look up the employee details view to get the employee appraisal details from the current database
var curDB:NotesDatabase = session.getCurrentDatabase();
var vwlkApprView:NotesView = curDB.getView("vwlkAllApprApper");
var collDocAppr:NotesDocumentCollection = vwlkApprView.getAllDocumentsByKey(sessionScope.EmployeeID);
if(collDocAppr.getCount() != 0){
return collDocAppr;
}
return null;}]]></xp:this.value>
<xp:panel id="pnlFG">
<xp:this.data>
<xp:dominoDocument formName="frmAppraisal" var="appraisalDoc"
action="editDocument" documentId="#{javascript:apprDoc.getUniversalID();}">
<xp:this.querySaveDocument><![CDATA[#{javascript:var apprDoc:NotesDocument = appraisalDoc.getDocument();
if(requestScope.SubmitFG == true){
apprDoc.replaceItemValue("CurrFGRRStatus","1");
apprDoc.save();
}}]]></xp:this.querySaveDocument>
</xp:dominoDocument>
</xp:this.data>
<xp:tr>
<xp:td styleClass="tdCls" style="width:2%">
<xp:label id="SrNo">
<xp:this.value><![CDATA[#{javascript:var index = parseInt(docIndex)
index = index + 1;
index.toString();}]]></xp:this.value>
</xp:label>
</xp:td>
<xp:td styleClass="tdCls" style="width:20.0%">
<xp:label id="ApeName">
<xp:this.value><![CDATA[#{javascript:return apprDoc.getItemValueString("AppraiseeName");}]]></xp:this.value>
</xp:label>
</xp:td>
<xp:td styleClass="tdCls" style="width:15.0%">
<xp:label id="ApeGrade">
<xp:this.value><![CDATA[#{javascript:return apprDoc.getItemValueString("Appraisee_Grade");}]]></xp:this.value>
</xp:label>
</xp:td>
<xp:td styleClass="tdCls" style="width:15.0%">
<xp:div style="text-align:center">
<xp:label id="appeTotImpRate"
style="font-size:10pt;color:rgb(255,0,0);font-weight:bold">
<xp:this.value><![CDATA[#{javascript:return apprDoc.getItemValueDouble("AppeTotImpRate").toFixed(2);}]]></xp:this.value>
</xp:label>
</xp:div>
</xp:td>
<xp:td styleClass="tdCls" style="width:15.0%">
<xp:div style="text-align:center">
<xp:label id="apprTotImpRate"
style="color:rgb(255,0,0);font-size:10pt;font-weight:bold">
<xp:this.value><![CDATA[#{javascript:return apprDoc.getItemValueDouble("ApprTotImpRate").toFixed(2);}]]></xp:this.value>
</xp:label>
</xp:div>
</xp:td>
<xp:td styleClass="tdCls" style="width:15.0%">
<xp:div style="text-align:center">
<xp:label id="revTotImpRate"
style="font-size:10pt;color:rgb(255,0,0);font-weight:bold">
<xp:this.value><![CDATA[#{javascript:return apprDoc.getItemValueDouble("RevTotImpRate").toFixed(2);}]]></xp:this.value>
</xp:label>
</xp:div>
</xp:td>
<xp:td styleClass="tdCls" style="width:10.0%">
<xp:div style="text-align:center">
<xp:comboBox id="appeGrades"
value="#{appraisalDoc.ApperFinalGrade}" style="width:50.0px"
disableClientSideValidation="true">
<xp:this.validators>
<xp:validateRequired>
<xp:this.message><![CDATA[#{javascript:var index = parseInt(docIndex)
index = index + 1;
"Please select a final grade in row number " + index.toString();}]]></xp:this.message>
</xp:validateRequired>
</xp:this.validators>
<xp:selectItem itemLabel="-"
itemValue="">
</xp:selectItem>
<xp:selectItem itemLabel="1"
itemValue="1">
</xp:selectItem>
<xp:selectItem itemLabel="2"
itemValue="2">
</xp:selectItem>
<xp:selectItem itemLabel="3"
itemValue="3">
</xp:selectItem>
<xp:selectItem itemLabel="4"
itemValue="4">
</xp:selectItem>
<xp:selectItem itemLabel="5"
itemValue="5">
</xp:selectItem>
</xp:comboBox>
</xp:div>
</xp:td>
</xp:tr>
</xp:panel>
</xp:repeat>
答案 0 :(得分:0)
使用简单操作“保存数据源”的按钮怎么样?这应该保存XPage上可用的所有数据源。
答案 1 :(得分:0)
重复元素的计算效率不高 - JSF生命周期将使您查找值两次。你可以试试这个:
// If we looked them up before we don't need to do anything
if (viewScope.approveIDs) {
return viewScope.approveIDs;
}
// Look up the employee details view to get the employee appraisal details from the current database
var curDB:NotesDatabase = session.getCurrentDatabase();
var vwlkApprView:NotesView = curDB.getView("vwlkAllApprApper");
var collDocAppr:NotesViewEntryCollection = vwlkApprView.getAllEntriesByKey(sessionScope.EmployeeID);
// Don't do a count, slow!
var result = new java.util.Vector();
// Add all unids
var ve:NotesViewEntry = collDocAppr.getFirstEntry();
while (ve != null) {
var nextVe = ve.getNextEntry(ve);
result.add(ve.getUniversalId()); // eventually check to avoid categories?
ve.recyle();
ve = nextVe;
}
viewScope.approveIDs = result.isEmpty() ? null : result;
collDocAppr.recyle();
vwlkApprView.recycle();
return viewScope.approveIDs;
此代码(关闭我的内存,因此检查语法)有一些值得注意的属性:
try { } catch(e ) { }