logo

A little teaser for you

While I finish off the article I've got planned for this week I thought I would share the example database with you. There's a copy online. The curious hackers among you might want to try and figure out how it works.

Start off by looking at the form that acts as a "view". Switch between the different regions to see the list of countries chage. What this demonstrates is a way of working with view data without trips to the server. In this case the page loads the whole view just once and holds it all in JavaScript arrays. Why not use XML I hear you thinking? Well, indeed, why not. Looking back I probably should have done. This solution was something I cooked up when I was big in to JavaScript and not so hot on XML. What it now shows is a way to work with a whole view without XML. This would be handy if the browsers you are aiming at can't use XML. Some can't!

In order to help me stress-test it I've left Anonymous access as Author and was going to ask you guys to help me fill in the list of countries from the CIA's World Factbook. Instead, I created a few and copied and pasted them until there were about 450. What I'll try and do it take this to the point where it passes the conventional 64KB and see what happens.

So, there you go. Have a play and see what you think. It was hard to come up with an example of using this that best demonstrated its use. Don't go thinking it's limited to this type of scenario though. You can use it in forms as well, where you would normally have a DBLookup. Maybe I should add another demo to that database before I write the article.

Update: I added this form which shows the same data from the same view being used in an entirely different way. Probably a more useful way at that. In this scenario the user select a region. JavaScript then queries all the array objects to find all countries in that region and populates the country selection list. Choose a country and it can easily fill in some of the fields for you, with data from the view.

Anyway, I'm off to find this....

Comments

  1. Damn,

    I was adding something similar to my new template as a dynamically generated JavaScript example. I based it around this excellent example:

    {Link}

    I am off to try and think of something original.

    Looking forward to the article.

    • avatar
    • mt69clp
    • Tue 23 Sep 2003 06:47

    Nice solution. Normally I would use the pinpoint applet and LiveConnect for such purposes because it is somewhat more sophisticated but last time I used it (2 years ago) it was slow and error prone. The DIIOP task regularly crashed and IE5 had problems with the applet.

  2. Did a similar thing on dominoblog - as I wanted to use xml but couldn't rely on all browsers supporting the method - its works very well

    • avatar
    • Gaston
    • Tue 23 Sep 2003 08:16

    Sorry Jake,I was playing with your database and remenber that the last time I played with this kind of things, I was annoyed by the ' symbol, so I added the country "Cote d'ivoire"...

    this line needs to be fixed by doing some backslashing...

    Middle East.addCountry("code d'ivoire", "B93C6BC1FD0C428286256DAA00485E1D", "2123120", "500000");

    Gaston

    • avatar
    • David Frahm
    • Tue 23 Sep 2003 08:31

    All I'm getting is errors in IE 5.5 and Firebird.

    Is this because of Gaston's addition?

  3. Has anyone had issues with serving up javascript, css, etc. from Domino in weird ways like this?

    For example, the MIME type is not correct... and althgouh I've never seen that cause a problem, it could if the user agent were extremely strict.

  4. I'm getting a javascript error and can't get anywhere. I also assume that it is improperly handling the apostrophe in Gaston's entry.

    • avatar
    • HUK
    • Tue 23 Sep 2003 08:48

    ditto here on the js errors, looking forward to the article jake

    • avatar
    • Michael McMahon
    • Tue 23 Sep 2003 08:58

    I agree with Gaston. Strip the space out of the 'Middle East' on this line:

    Middle East.addCountry("code d'ivoire", "B93C6BC1FD0C428286256DAA00485E1D", "2123120", "500000");

    That should fix up the JS error.

    • avatar
    • Jake
    • Tue 23 Sep 2003 10:00

    Woops. Okay, it's far from perfect so far. For now I have removed Gaston's entry so that it works. I will fix it later...

    Jake

    • avatar
    • Ian B
    • Tue 23 Sep 2003 12:54

    Yeah, I did this a way back when you started talking about arrays (fred & wilma, if I recall correctly?) and did a similar thing on a viewtemplate form. It's really useful if you have a scroll wheel as you can quickly go through the whole list - try it. You appear to be writing the HTML using JScript, I just used divs around each category and used CSS to hide them. Then the selection just set the required div to display.

    • avatar
    • Ken
    • Tue 23 Sep 2003 12:59

    Has anyone used this methodology?

    {Link}

  5. Jake,

    If you're talking about the Notes field 64k limit, I posted a workaround for this here:

    {Link}

    I've pushed some really complex generated HTML tables into a single notes field. You could use a similar technique to build and parse a large array of javascript.

    If you're talking about some limit in javascript I am unaware of, you just educated me. :-)

    Jerry

    • avatar
    • Fredrik Stockel
    • Tue 23 Sep 2003 15:24

    This is a technique that I use very often. It's powerful and easy to implement. I have noticed that some characters might be transformed into something “unreadable” unless you are careful with the charset (needs to be set explicitly sometimes to avoid such problems).

  6. David Frahm - With regards to Domino MIME types and potential problems - I found my first one recently :) I am developing an application that will sit behind Tivoli Access Manager, a security product that includes a reverse proxy that automatically rewrites URLs within your pages before it serves them. Anyway, this product adds a bit of JavaScript that sets a cookie to all text/html pages. This broke my app initially because my CSS and JS were being served as text/html and having "<script>" tags at the top wasn't healthy for them.

    It kind of annoys me actually, it sticks these "<script>" tags before the DOCTYPE on the HTML, so I don't think the pages would validate anymore. But that's another story.

  7. innerHTML? Jake, you cheatin' <inset disparaging term here>!

    Where's all of the document.createElement() and element.appendChild() and element.appendTextNode() and so forth? Do you not know that there are people using builds of Mozilla/Gecko that didn't support proprietary IE extensions? (I'm kinda mad 'cos I did something similar when the latest Netscape browser had dropped support for innerWhatever. Support's back now, but that will never get me back the time I spent pressing the extra 18,000 keys to use the DOM methods.)

  8. Welcome to the world of geocaching. I've been at it for about year. Alot of DNF's in my list as well. Its a great way to get the nose out of a monitor and into the great outdoors.

    • avatar
    • Ton Gielen
    • Wed 24 Sep 2003 04:09

    I hope this can be usefull again for me, i love your articals. I already used the RSS Feed and SMTP articals. It is the way you write. Very clear and open for comments. I thought it is maybe challenging to make the view like this view in Vbscript: {Link} but then make it in javascipt in a lotus notes database. The view allows you to sort the rows and drag the colums from left to right and right to left. Very user friendly. I■m waiting for the rest of the artical and hope my comment is used.

    Keep it going.

    • avatar
    • Jake
    • Wed 24 Sep 2003 04:49

    Stan - leave it with me. That hadn't even crossed my mind. Tut, tut. Shame on me.

    Ton - It's easy to create that table in Notes with a fairly standard view. All you need to do is add all the .htc behaviour files to the database and make sure they get included with the view....

Your Comments

Name:
E-mail:
(optional)
Website:
(optional)
Comment:


About This Page

Written by Jake Howlett on Tue 23 Sep 2003

Share This Page

# ( ) '

Comments

The most recent comments added:

Skip to the comments or add your own.

You can subscribe to an individual RSS feed of comments on this entry.

Let's Get Social


About This Website

CodeStore is all about web development. Concentrating on Lotus Domino, ASP.NET, Flex, SharePoint and all things internet.

Your host is Jake Howlett who runs his own web development company called Rockall Design and is always on the lookout for new and interesting work to do.

You can find me on Twitter and on Linked In.

Read more about this site »

More Content