Wednesday, January 30, 2008

Embed multiple standalone forms on a domino form using DHTML

By standalone I mean that when you submit a form, you don't submit all the others/the main form.

I decided to make this when I read a question in Jake's latest article, How to Embed a Login Form on All Lotus Domino Pages.

The question is not directly connected to this blogpost, but somewhat.

The question:
Hi Jake,

We are getting two HTML form tag in view source of page in browser, one form tag for main form and other which is login form.

My question is, How will I handle when we are submiiting the Login form ? Will it submit the main form as well ?

Could you please help me

Regards
Ajay B Mali


The demoapp loads another form using an iframe. Using DHTML I pick the form out of the iframe and inject it at the top or bottom of the form that is open. The reason for either top or bottom is that forms can't be nested (read Jake's excellent article for more info). If you want it in a specific position on the page, CSS may help you.

The reason for iframe and not XHR (Ajax), is that XHR returns text. With the iframe, I can more or less pick what I want out of the "iframed" document, the way I would on the "main" document.

>> The demoapp (Names-form)

Tested in Opera 9, IE7 (Vista) and Firefox 2

5 comments:

Nate said...

So, why strip it from the iframe and then inject it? Why not just present the iframe?

I can't figure out why people avoid iframes so frequently. :(

I mean, it seems to me all you need is an iframe with a SRC of the current URL with '&login&redirect=' + location.href attached to the end.

What am I missing here?

Unknown said...

If it's a login, you still have to reload the (main) page. Doing that with an iframe requires scripting in the "embedded" form (either in the markup, or dynamically).

It's been a while since I've worked with visible iframes, but from what I can remember, it's sometimes a hassle to get them to look alike (dimensions/scrollbars) in the major browsers.

When modifing documents related to the one one is working on, I'd probably use a modal dialog/lightbox with an iframe.

I guess it comes down to picking the "tool" one feels right for the job.

Nate said...

"Doing that with an iframe requires scripting in the "embedded" form (either in the markup, or dynamically)."

On a successful login, you want to tell the parent to refresh. That seems pretty minor to me. Heck, you could make the IFRAME request a login to ANY static secured page on your site. When the authenticated user gets to that page, it's displayed in the IFRAME context. As long as the two pages are served from the same domain, all you need is... window.parent.location.refresh() don't you?

Unknown said...

That is correct. By scripting, I meant Javascript(ing).

Like a lot of other elements of programming, I guess this one also comes down to the personal preference/mindset of the programmer at hand.

Ajay B Mali said...

Hi Tommy

Thanks for database you provided.

Its work really cool. I have downloaded and test it.

regards

Ajay B Mali