我在名爲「Add Line Item」的視圖中有一個按鈕。您選擇一個文檔,然後點擊此按鈕。目的是我們創建一個新文檔,其中所選文檔的值被填入新文檔中。在beforePageLoad事件中設置組合框的值
在視圖按鈕中,我使用長字符串設置了sessionScope變量。我用「〜」分隔每個條目。在每個條目中,第一件事是該字段的實際名稱。接下來是該領域的價值。這兩個由管道「|」分隔。如果字段的實際值是一個數組,他們自然會用分號分隔它們。我提到所有這些,以便下面的代碼可以被理解。
在我啓動的窗體中,在beforePageLoad事件中,我有以下幾點:
var AddingNewLine = sessionScope.get("AddingNewLine");
if (AddingNewLine != null) {
fieldsArray = AddingNewLine.split("~"); // make an array that has the field names & its value(s)
for (i = 0 ; i < fieldsArray.length ; i++) {
splitValue = fieldsArray[i].split("|"); // now we make an array out of the entry. value 0 will be
fieldName = splitValue[0]; // the name of the field. value 1 will be the values which
fieldValues = splitValue[1].split(";") // in turn will be split into an array
var f = "PayRates:HourlyRates:CPrompts:IssuingCountry:ServiceCurrency:ReceivedDate:InvoiceDate:Client:InvoiceNumber:WBS";
if (f.search(fieldName) >= 0) {
currentDocument.setValue(fieldName,fieldValues);
if (fieldName == "CPrompts") { var CPrompts = fieldValues }
}
}
// new doc but adding new line item or replicating? then get our prompts from the original doc
for (i = 0; i < CPrompts.length ; i++) {sessionScope.put("CPrompt"+(i+1),CPrompts[i])}
}
注:我篩選出的數值與「F」變量現在,因爲我跟他們不同的問題
反正,我所有的文本框都得到更新,但組合框不是(這恰好是IssuingCountry,ServiceCurrency,Client和WBS)
我已經驗證過,當我執行currentDocument.setValue時,字段名稱及其值與print語句是正確的。做一個currentDocument.replaceItemVale。似乎不適用於comboBox類型字段。這也適用於日期值字段。
組合框領域例如:
<xp:comboBox
id="IssuingCountry"
style="width:160.0px"
value="#{FInvoiceDoc.IssuingCountry}">
<xp:selectItem
itemLabel="United States of America"
itemValue="United States of America"
id="selectItem1">
</xp:selectItem>
<xp:selectItems id="selectItems1">
<xp:this.value>
<![CDATA[#{javascript:@DbLookup("", "Keywords", "Countries", 2)}]]>
</xp:this.value>
</xp:selectItems>
</xp:comboBox>
難道是因爲我需要以某種方式更新itemLabel?如果是這樣,怎麼樣?
日期字段示例;
<xp:inputText
value="#{FInvoiceDoc.ReceivedDate}"
id="ReceivedDate"
style="width:85px">
<xp:this.converter>
<xp:convertDateTime
pattern="MM/dd/yyyy">
</xp:convertDateTime>
</xp:this.converter>
<xp:dateTimeHelper
id="dateTimeHelper1">
</xp:dateTimeHelper>
</xp:inputText>
感謝您向我展示數組的名稱和值集成開發環境。儘管如此,仍然有完全相同的問題。組合框和日期不更新。以下是我使用其中一個代碼填充的代碼; prepopulate.push({「name」:「IssuingCountry」,值:doc.getFirstItem(「IssuingCountry」)。getValues()}); – cjames728
啊,我需要getValueString。這是行得通的。謝謝! – cjames728
名稱/值是JavaScript對象的一部分。你既不限於2個屬性也不限於名稱。您可以將其稱爲字段/內容並添加數據類型屬性。這就是爲什麼JSON非常受歡迎 – stwissel