Subject: $$SearchTemplateDefault and HTML content
I’ve been wrestling with this as well.
From my research, the problem is that when you use the searchview URL command, Domino internally tries to open the applicable $$SearchTemplate as a form in edit mode, which doesn’t work when you set the content type to anything other than Notes. With a $$ViewTemplate, you can get around this by using a page instead of a form, but with $$SearchTemplate it doesn’t recognize pages.
So, here’s my solution. It’s a bit of a hack, but such is life. I wrote a Java agent that looks up a URL and writes the URL’s response as the Java agent’s response. So, it’s a URL calling a URL. The Java agent begins it’s response with
Content-type: text/xml
<?xml version="1.0" encoding="UTF-8"?>
so it will be recognized as xml (which I wanted in my case). Also, because I wanted only part of the response from the searchview URL (discarding the tags that domino adds around the $$SearchTemplate content), I added a bit of intelligence so it would be selective in what part of the searchview response the agent would relay:
protected void search2 (PrintWriter output) throws NotesException, IOException {
URL url = new URL("http://www.whatever.com/website.nsf/MyView?SearchView&query=[companyabbreviation]=HI%26[marketAbbreviation]=DFW%26[CommunityID]=6LZSLQ");
URLConnection connection = url.openConnection();
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String inputLine;
boolean write = false;
while ((inputLine = in.readLine()) != null) {
if (!write && inputLine.startsWith("<table")) write = true;
if (write) {
output.println(inputLine);
output.flush();
}
if (write && inputLine.startsWith("</table>")) write = false;
}
in.close();
}
In terms of performance, it is a bit slower than just calling the searchview URL directly, but you could optimize by making it a Java servlet (which loads once and then stays resident in memory. I’ll probably do that at some point.
Still, this approach is a LOT faster than traversing a large ViewEntryCollection to grab the exact same data and serve it back. If you only have a couple hundred results max, the difference may be negligible, but in my case I have to plan for a couple thousand at most, and needed the response to stay under 30 seconds or so as a worst case.