Using Lists to process dynamic forms
Category show-n-tell thursday
I've said it before and I'll say it again: LotusScript's List is under-utilized. Reference this previous post if you're curious about why I'm so infatuated with this datatype. For this week's installment of SnTT, however, I submit for your consideration my approach to handling dynamic web forms using a List.
When a standard Domino form is submitted by a browser, the value of each field defined on that form is conveniently written to the database. As we all know. But, as many of us have had occasion to bemoan, if additional fields are added in the HTML, Domino gets upset because there's no corresponding field defined in the design element. Others have described various approaches to circumventing this behavior, so I won't belabor that here. But what if you want to define an entire form dynamically? That's where a List comes in handy:
Once the list is populated, you can Forall through it and do whatever you want with the data, such as assigning field values on a document, for example:
Enjoy...
Technorati tag: Show-n-tell thursday
I've said it before and I'll say it again: LotusScript's List is under-utilized. Reference this previous post if you're curious about why I'm so infatuated with this datatype. For this week's installment of SnTT, however, I submit for your consideration my approach to handling dynamic web forms using a List.
When a standard Domino form is submitted by a browser, the value of each field defined on that form is conveniently written to the database. As we all know. But, as many of us have had occasion to bemoan, if additional fields are added in the HTML, Domino gets upset because there's no corresponding field defined in the design element. Others have described various approaches to circumventing this behavior, so I won't belabor that here. But what if you want to define an entire form dynamically? That's where a List comes in handy:
- Create an agent in the database that will process the form submission. In other words, the form doesn't have to exist in the same database, or even in Domino; this approach allows a Domino database to process submissions from any HTML form, regardless of how its content is generated. One application of this approach, however, would be to generate the form dynamically using Domino, i.e. a page element doing DbLookups or another agent that prints the form HTML to the browser.
- Set the form action to the URL of the form processing agent and the method to "post".
- Pull the field name and value pairs into a list in the form processing agent:
Dim sessCurrent As New NotesSession
Dim docContext As NotesDocument
Dim strRequestContent As String
Dim lstrFieldPairs List As String
Dim varFieldPairs As Variant
Set docContext = sessCurrent.DocumentContext
Let strRequestContent = docContext.GetItemValue("Request_Content")(0)
Let varFieldPairs = Split(strRequestContent,"&")
Forall strFieldPair In varFieldPairs
Let lstrFieldPairs(Strleft(strFieldPair,"=")) = Strrightback(strFieldPair,"=")
End Forall
Once the list is populated, you can Forall through it and do whatever you want with the data, such as assigning field values on a document, for example:
Forall strFieldValue In lstrFieldPairs
Call docTarget.ReplaceItemValue(Listtag(strFieldValue), strFieldValue)
End Forall
Enjoy...
Technorati tag: Show-n-tell thursday








Comments
Posted by Chad Schelfhout At 00:36:29 On 03/02/2006 | - Website - |
Sean---
Posted by Sean Burgess At 14:03:15 On 03/24/2006 | - Website - |