그렇습니다. Java로 변환 할 수없는 SSJS의 예는 생각할 수 없습니다. 여기에 Tim Tripcony의 SSJS가 포팅되었습니다. 자바.
import java.util.HashMap;
import java.util.Map;
import lotus.domino.*;
import com.ibm.domino.xsp.module.nsf.NotesContext;
public class TypeAhead {
public static String directoryTypeAhead(String searchValue) {
String returnList = "";
try {
Database directory = NotesContext.getCurrent().getCurrentSession().getDatabase("", "names.nsf");
View allUsers = directory.getView("($Users)");
Map<String, HashMap<String, String>> matches = new HashMap<String, HashMap<String, String>>();
Map<String, String> individualMatches = new HashMap<String, String>();
Map<String, Boolean> includeForm = new HashMap<String, Boolean>();
includeForm.put("Person", Boolean.TRUE);
includeForm.put("Group", Boolean.TRUE);
ViewEntryCollection matchingEntries = allUsers.getAllEntriesByKey(searchValue, false);
ViewEntry entry = matchingEntries.getFirstEntry();
int resultCount = 0;
while (entry != null) {
Document matchDoc = entry.getDocument();
String matchType = matchDoc.getItemValueString("Form");
if ((Boolean)includeForm.get(matchType)) {
String fullName = matchDoc.getItemValue("FullName").elementAt(0).toString();
if (matches.get(fullName) == null) {
resultCount++;
Name matchName = NotesContext.getCurrent().getCurrentSession().createName(fullName);
individualMatches = new HashMap<String, String>();
individualMatches.put("cn", matchName.getCommon());
individualMatches.put("photo", matchDoc.getItemValueString("photoUrl"));
individualMatches.put("job", matchDoc.getItemValueString("jobTitle"));
individualMatches.put("email", matchDoc.getItemValueString("internetAddress"));
matches.put(fullName, (HashMap<String, String>) individualMatches);
}
}
if (resultCount > 9) {
entry = null;
}
else {
entry = matchingEntries.getNextEntry(entry);
}
}
returnList = "<ul>";
for (Map<String, String> match : matches.values()) {
String matchDetails = "<li><table><tr><td><img class=\"avatar\" src=\"" + match.get("photo") + "\"/></td><td valign=\"top\"><p><strong>" + match.get("cn") + "</strong></p><p><span class=\"informal\">" + match.get("job") + "<br/>" + match.get("email") + "</span></p></td></tr></table></li>";
returnList += matchDetails;
}
returnList += "</ul>";
} catch(Exception e) {
System.out.println(e);
}
return returnList;
}
}
지금까지 모든 확장 라이브러리를 만드는 당신은 정말 당신이 플러그인 항아리에 넣어되고 싶은 생각 얻을 후 새 8.5을 사용할 수있는 기능 및 업데이트 사이트를 만들해야 .3 모든 서버에 그것을 복제하는 기능.
당신은 당신의 xpage의 내부에서 다음을 수행하여이 코드를 사용할 수 있습니다 : 당신이 어떤 XSP 라이브러리 (예 : XSP 스타터 키트)에 토비의 예와 같이 클래스를 추가하는 경우
<xp:inputText id="inputText1" value="#{viewScope.someVar}">
<xp:typeAhead mode="partial" minChars="1" valueMarkup="true"
var="searchValue"
valueList="#{javascript:return com.tobysamples.demo.TypeAhead.directoryTypeAhead(searchValue);}">
</xp:typeAhead></xp:inputText>
를, 그것은 런타임에 사용할 수 있습니다 해당 라이브러리에 대해 정의 된 종속성이있는 모든 응용 프로그램. 또한 라이브러리를 전역으로 설정하면 종속성이 정의되지 않은 경우에도 모든 응용 프로그램에서 사용할 수 있습니다. –
P. 당신은 정말로 StringBuilder와 같은 것을 사용하여 단지 연결 대신 모든 마크 업을 구성해야합니다. 자바 스크립트에서 + = 접근법은 괜찮습니다. (거대한 연결의 경우 배열로 푸시 한 다음 조인을하는 것이 더 효율적이지만) 자바에서 문자열 연결은 비효율적입니다. –