Yes, I canβt come up with an example of any SSJS that cannot be converted to Java, here is Tim Tripcony SSJS ported to Java.
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; } }
As for creating it in the extension library, all you really need to do to get what I think you need is to put it in the Jar plugin and create a site with a function and update, then you can use the new 8.5 functionality .3 for copy it to all your servers.
You can use this code by doing the following inside your xpage:
<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>
source share