Xpages - 传递 在Arraylist

问题描述 投票:0回答:1

我正在尝试添加一个href到Arraylist,这很好地添加到Arraylist,但链接被打破。 URL中的问号(?)后面的所有内容都不包含在链接中。

有什么我想念的,代码如下:

private String processUpdate(Database dbCurrent) throws NotesException {

int intCountSuccessful = 0;
View vwLookup = dbCurrent.getView("DocsDistribution");
ArrayList<String> listArray = new ArrayList<String>();
Document doc = vwLookup.getFirstDocument();

while (doc != null) {
    String paperDistro = doc.getItemValueString("DistroRecords");
    if (paperDistro.equals("")) {
        String ref = doc.getItemValueString("ref");
        String unid = doc.getUniversalID();
        // the link generated when adding to Arraylist is broken
        listArray.add("<a href=\"gandhi.w3schools.com/testbox.nsf/distro.xsp?documentId=\"+ unid + \"&action=openDocument\">" + ref + "</a>");
    }
    Document tmppmDoc = vwLookup.getNextDocument(doc);
    doc.recycle();
    doc = tmppmDoc;
}

Collections.sort(listArray);

String listString = "";
for (String s : listArray) {
    listString += s + ", \t";
}

return listString;

}
java arraylist xpages href xpages-ssjs
1个回答
3
投票

你有一个"逃离unid值的问题,因为你的URL变成了gandhi.w3schools.com/testbox.nsf/distro.xsp?documentId="+ unid + "&action=openDocument

如果你使用String.format()和单引号来生成a标记会更容易阅读:

listArray.add(String.format(
    "<a href='gandhi.w3schools.com/testbox.nsf/distro.xsp?documentId=%s&action=openDocument'>%s</a>", 
    unid, ref));
© www.soinside.com 2019 - 2024. All rights reserved.