Wednesday, December 19, 2007

Doing lookups on the web

Update, 20.12.07: Demo-application done.

I've finally gotten started with my templating-demo again.

One of the examples I promised was Ajaxy lookups (using the same view on the Web as in Notes). To make this happen, I thought it would be enough going to use ?OpenView&startkey=hello, but the effect of that "command" is start with documents starting with hello, then show the rest of the documents in the view.

A quick visit to my friend, google, sendt me along to an article on CodeStore.net. "Hidden" in the comments-section was my answer:

Alex Hernandez (Thu 5 May 2005 10:00) website / e-mail

Jake, I've been facing a similar problem when reading the "startkey", if the key doesn't exist, it returns the next set of documents, which is wrong. Now, if you add the "untilkey" to the url you can grab only the documents you need. This is true everytime you know how to compose the untilkey key, What I did was just adding a "_" to the end of my know startkey.

for example:
http://server/db.nsf/view?openview
&startkey=alex
&untilkey=alex_


originally If I searched for "alexh" and the key doesn't exist, it returned the rest of the docs. now with the until key, it search for docs with ket between "alexh" and "alexh_" wich returns no documents, and that's what I expected.

.::AleX::.


Thank you Alex, Jake and google!

3 comments:

Jake Howlett said...

Brilliant!
This very same problem BUGged me the other day and I just resigned myself to having to explain it away as a "quirk" if the customer ever noticed.
Then I read this post and remembered Alex's response to my post and managed to solve it.
So thank you for thanking me. We're all happy...
Jake

Alex Hernandez said...

Thanks for the kind words Tommy, I read Codestore daily and is a great source when looking for Domino related hacks, tips and tricks ;-). I prefer to search there than google when talking about nice Domino solutions.

Merry Christmas!

.::AleX::.

Unknown said...

Codestore is THE repository for Domino (Web) developers. Jake posts great articles, and there are a lot of great/helpful comments.

--

Merry Christmas to you too, Alex!