logo

Views and Forms with Same Name

Since maybe version two or three of this site I've used a special document to store images and attachments used in blogs and articles. The view is called Resources and you all have access to read it. The view shows document created using the Resource form.

When I want an image in a post I add it to a document and reference it with a relative URL, like so:

<img src="rsrc/bloggifs19/$file/none.gif" />

Notice I've used the view's alias of "rsrc"? Note also that the Resource Form has the same alias and you might see where I am going with this.

Until now this has all worked perfectly. Then I started creating new replicas on Domino 6 servers and all the images in blog entries appeared broken, following HTTP 400 requests to show them. As this was on my dev server here I didn't worry too much about it. Now that I'm working on a new version I thought I'd better work it out. First thing I did was try and open a broken image URL directly. Domino returned:

HTTP Web Server: Lotus Notes Exception - Note item not found

Stripping away at the URL I opened //server/store.nsf/rsrc/bloggifs19/, which threw this error:

HTTP Web Server: Unknown Command Exception

Stepping back further to the basic URL //server/store.nsf/rsrc/ I found the problem, staring me in the face. This URL opened the Form and not the View.

Somewhere along the lines, Domino has decided that Forms takes precedence over Views when you access them by name only and there are two with the same name. This breaks all my images in all my blogs and articles, but only in new copies/replicas I create on Domino 6 servers. Strangely, this version, as it stands, on Domino 6 is okay.

The moral is obvious. Don't give any two elements the same name or alias. To fix it in my case I changed the alias of the form (if I'd changed the view name I would have had to change the URL of every image!). I then ran an agent on the Resource view that updated the Form field. Once again, all is well aboard the good ship CodeStore.

Comments

    • avatar
    • Doug
    • Tue 8 Feb 2005 05:41

    The domino server looks at the names of elements in the same order as they appear in Designer when you open a database.

    • avatar
    • Jake
    • Tue 8 Feb 2005 06:30

    That's what I'd always thought Doug. But that doesn't explain why one copy of this DB works and the other doesn't.

  1. Doesn't it look for them in the order of the noteID.

    if you created the view first and then the form then the view would have the lower NotesID and thus be found first.

    When you create a new copy of the database the notes are created in the order that they are found, so forms first, then views. As a copy will have different NotesID the notes ID of the form is now lower then that of the view and that means it's now found first.

    • avatar
    • Jake
    • Tue 8 Feb 2005 07:12

    Makes sense Declan but it's the same story with new replicas of the database.

  2. I believe Declan is correct. Recalling a conversation I had with Ned once, it is the order in which the notes appear in the design collection, which is sorted by noteid. This can vary from one replica to another because replication does not preserve noteids. You will probably find that if you (a) rename the form note in one replica, (b) take the form note from another replica and cut it to the clipboard, (c) then paste it from the clipboard back into the first replica, then Domino will find the view note as it did in the original because the pasted form note will have a higher noteid than the view note. (This is presuming that you haven't deleted any docs from the replica, which might have freed up a low noteid for re-use.)

    In any case, you have reached the correct conclusion for your moral. My preference is usually to use a singular name for the form, and a plural name for view. I.e., I might have used "rsrcs" and "rsrc" in this case.

    -rich

    • avatar
    • Mike
    • Tue 8 Feb 2005 07:37

    Is not good practice in general to avoid redundant naming of elements?

    • avatar
    • Jake
    • Tue 8 Feb 2005 07:50

    Thanks Richard. I *think* I get it now. This is the last time I name two elements the same. Can't even remember why I did in the first place! (Not something I'd normally do. Honest).

    Mike?

    • avatar
    • Stephen Neal
    • Tue 8 Feb 2005 07:57

    Under Notes 4.5 and 4.6, giving a view and form the same name could have lethal consequences. I remember corrupting a couple of databases this way.

    • avatar
    • Mike
    • Tue 8 Feb 2005 08:03

    Sorry Jake ... I was pretty much trying to say the same thing as Richard. Guess I should proof read a little better before hitting Post. When I name a form "doc", I usually name the view "doc_view" or something along those lines. It's 9AM here - the brain is just starting to wake up.

    -- Mike

    • avatar
    • Jake
    • Tue 8 Feb 2005 08:23

    No worries Mike. I wasn't sure what you meant by redundant naming. Things with names that don't tell you what they are?

    • avatar
    • Mike
    • Tue 8 Feb 2005 08:34

    Things with names that are the same name as other things. Redundant is probably not the right word, but my last post holds the disclaimer for the misfire of the brain. I swear I have a college degree. No, really, I do.

    • avatar
    • Greg
    • Tue 8 Feb 2005 16:21

    I agree with not naming multiple elements the same except for views. I sometimes give several views more than one alias, and ensure that the last alias is the same for all of them. That way they can all share a $$ViewTemplate - it saves having to create multiple $$ViewTemplates with the same formatting.

  3. Way back when I was first learning this stuff someone told me to preface the alias with a code denoting design element type (e.g. vwResrcs, fResrc). I didn't really think about why you'd do this but just went with it. It all makes sense now :) ...

    • avatar
    • Ben
    • Tue 8 Feb 2005 21:18

    This is a decent discussion going on here. Perhaps it's time to compile the ultimate list of naming conventions? Could be a useful reference if we were able to agree on things! BTW, I really like to use i, l and j as integers in LotusScript ;)

  4. Ben... n rules! ;-) i and j are ok, too. I use them all the time. But l?? That's just wrong!

    • avatar
    • wmoze
    • Wed 9 Feb 2005 01:46 PM

    I ran into that same issue a while back.

    {Link}

    In my case, simply upgrading to R6.03 caused the problem. I've made it a habit since then to try and prepend a view name with v and a form with f.

    fCategoryLookups

    vCategoryLookups

    I don't know if that is a standard for others but it is something I try and follow (most of the time anyway). Reminds me of working in VB where you named buttons cmdThisIsMyButton, frmThisIsMyForm...

    r,

    -w

  5. I ran into this problem recently when trying to convert CSS pages to CSS Resources. I had forgotten to remove the pages from the databases I added the resources to and couldn't understand why the changes I kept making in the CSS weren't showing up.

    Sean---

  6. Not just forms and views! I just had this problem, and spent four hours with this same exact problem (I knew you would have come across it, Jake so I just persevered and googled until I found something!).

    Anyway, in my case it was a view and a subform of all things. I renamed the subform and all was well again.

    Thanks for helping me out!

Your Comments

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


About This Page

Written by Jake Howlett on Tue 8 Feb 2005

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