Consider the following two URLs. The first one works, whereas the other throws an illegal exception error.
There's an obvious problem with both URLs but only a slight difference between them. Although both have two ?s in them the second one has more than 16 characters in the value passed as the query parameter. This, it seems, is what stops it working. As expected, the following URL does work.
It seems that Domino forgives the badly formed URL, but only to a point. One character too many and it starts to complain. Needless to say it took me some time to work this out.
You're probably wondering why I was using a badly-formed URL in the first place. Well, it's all part of life with Domino. Domino's insistence in having a strictly defined parameter (such as OpenView, EditDocument etc) as the first thing in all URLs can be a bind sometimes. Especially with all the new Ajaxy-type frameworks and plugins now at large.
In this case I was using the YUI AutoComplete widget. It "listens" to a field and polls it for changes. If it changes it sends requests to the server for an updated set of values. Based on this online example setup appeared as simple as:
oACDS = new YAHOO.widget.DS_XHR("./php/ysearch.php", "ResultSet.Result","Title"); oACDS.scriptQueryAppend = "output=json&results=100"; // Instantiate AutoComplete oAutoComp = new YAHOO.widget.AutoComplete("input","container", oACDS);
This is for a "normal" PHP scenario though. To get anything like this to work with Domino is always a bit of a challenge. First thing I did was copy the code and change it to look like this (note the highlighted change in bold):
oACDS = new YAHOO.widget.DS_XHR("getNames?OpenAgent", "Names","Name"); oACDS.scriptQueryAppend = "foo=foo"; // Instantiate AutoComplete oAutoComp = new YAHOO.widget.AutoComplete("input","container", oACDS);
The result is a URL like the broken ones I showed above which have two ?s when only one is allowed. The AutoComplete code obviously creates its own query string and appends it to the location of the search URL that you specify when creating the new YAHOO.widget.DS_XHR() object.
What I needed to do was find out how to pander to Domino's needs by adding the OpenAgent parameter up front. It turned out this wasn't as hard as I'd thought (I was thinking I'd have to hack the source code).
The first thing I did was find the non-minified source code to AutoComplete.js. In there I found this line in the initialisation section:
So every time a key is pressed in the search field it called the "onTextboxKeyUp" method. Searching the file for this method I soon found it and discovered it sets a timeout to call the _sendQuery() method. _sendQuery() points to the getResults() method, which, in turn, points to doQuery(). It's in this final method that we find this line of code:
var sUri = this.scriptURI +"?" +this.scriptQueryParam + "=" +sQuery +this.scriptQueryAppend;
In our case, scriptURI = "getName?OpenAgent", scriptQueryParam="query", sQuery="typed value" and scriptQueryAppend= "foo=foo". So the URL we end up is:
To get it to work all we need to do is make scriptURI = "getNames" and make scriptQueryParam = "OpenAgent&query". When the URL gets built with these new values there's only one question mark. It might be a hack but it didn't require over-writing any code, so I'd call it an elegant hack.
The AutoComplete object has the default value for scriptQueryParam set when it's created. It's logical to think we can go on to over-ride it — outside of the actual code — like so:
oACDS = new YAHOO.widget.DS_XHR("getNames", "Names","Name"); oACDS.scriptQueryParam = "OpenAgent&query"; oACDS.scriptQueryAppend = "foo=foo"; // Instantiate AutoComplete oAutoComp = new YAHOO.widget.AutoComplete("input","container", oACDS);
No more double ?s and it works fine now. So, what was the point of telling you all this then? Well, hopefully it's a lesson in hacking. A lesson in knowing how to frig things about to work with Domino. Never giving up and always knowing there's a way.Be prepared to get your hands dirty sometimes and delve in to the source code. Sometimes this is hard, but on this occasion it was refreshingly simple.