$$SearchTemplateDefault and HTML content

Hello. If anybody has a minute, I’ve been wrestling with this all day. I am trying to customize $$SearchTemplateDefault to display search results in a table I am trying to format via CSS. however, whenever I click the second tab on the form properties to render contents as HTML, I get a 404 return in the browser. I use this approach for all $$ViewTemplateDefaults but is rendering content as HTML prevented internally on $$SearchTemplateDefault? If I click “notes” in the second tab, the results will display, but obviously the table display is all skewed and not uniform with the views in the database.

A little more info…

The server log returns this error when it attempts to open $$SearchTemplateDefault with content set to HTML…

03/31/2008 08:10:11 PM HTTP Web Server: Application Exception - Documents treated as HTML cannot be edited [/Webtt.nsf/SearchView?SearchView&query=Test]

so…I’m not sure why $$SearchTemplateDefault will be any different than $$ViewTemplateDefault. They both only have the $$viewbody field…so what could be ‘edited’ in $$SearchTemplateDefault?

Thank you very much for reading this. Any input would be really appreciated.

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.