我有以下 java bean 代码,它在 sessionScope 的数组列表中存储选项卡列表,因此我不必为每个请求查找它。
public class BeanMethods {
private static final long serialVersionUID = 1L;
public Database db;
public ArrayList<String> userTabs;
public BeanMethods() {
db = ExtLibUtil.getCurrentDatabase();
userTabs = new ArrayList<String>();
}
public ArrayList<String> getUserTabs(String uid) throws NotesException {
if (userTabs.isEmpty()) {
userTabs = getUserTabs2(uid);
}
return userTabs;
}
public ArrayList<String> getUserTabs2(String uid) throws NotesException {
db = ExtLibUtil.getCurrentDatabase();
String key = "TAB_UID_" + uid;
DocumentCollection dc = db.getView("LookupKey").getAllDocumentsByKey(key, true);
Document d = dc.getFirstDocument();
while (d != null) {
String tabTitle = d.getItemValueString("Title");
userTabs.add(tabTitle + "|" + d.getItemValueString("UniqueId"));
d = dc.getNextDocument(d);
}
return userTabs;
}
}
我对此有一些疑问