dominoGuru.com
Your Development & Design Resource
Creating Documents via the URL-Command Method
02/08/2006 10:02 AM by Chris Toohey
The ?createdocument
and ?savedocument
are two very
useful Domino URL Commands that can be used in combination with affording
back-end design to allow practically complete web-based Domino Content
Management without having to rely on Domino-generated/housed forms. In this
entry, I will showcase the aforementioned web-based Domino Content Management,
complete with this method's various pros and cons.
We'll refer to the usage of ?createdocument
and
?savedocument
Domino URL Commands for Domino Content Management,
just so I don't have to type that long mess out again, as the URL-Command
Method. And while this URL-Command Method certainly wins the award for easiest
to implement, it generally doesn't make life easier for the Developer who needs
to maintain the solution. But before we get to the maintenance of the solution,
let's start off by delving into the build.
For an example, we'll be building a "For More Information" Sign-Up form - often something you see on public corporate websites, but a solution that has application in intranet and extranet environments just as well. Our sign-up form, to keep things simple, will attempt to gather 3 items of information from the user: their name, their email address, and their interest.
We'll start with a very simple form:
<form name="websignup" method="POST" action="">
<label for="name">Your Name</label>
<input type="text" name="name" /><br />
<label for="email">Your Email</label>
<input type="text" name="email" /><br />
<label for="interest">Your Interest(s)</label><br />
<textarea name="interest"></textarea>
<input type="submit" value="Sign Up!" />
</form>
This produces a very simple sign-up form, which I hope you've noticed is
missing a value in the action
attribute. Since you will use this
form to create a document in a Domino database, we will need to first create a
form that we will use to POST the sign-up information.
To do this, we simply create a form in our target database, which we will call "gendoc". And we will need the following fieldnames:
- name
- interest
- $$Return
Now, at this time, I should mention that it is very
important that you maintain the 1:1 naming relationship of the fields from you
submission HTML forms and your Domino form elements, as the URL-Command Method
relies on like-named elements transferring data. That now understood, the
fourth item on the above list, $$Return
, will be used to redirect
the user to a success or failure URL based on your application logic. While
there are caveats to this approach (the utilization of the
$$Return
field), we're trying to keep this simple at the first
installment here.
Now that we have our "gendoc" form, we add the following to the HTML-based
"websignup" form's action
attribute:
http://servername/database/gendoc?createdocument
Now, your form should look something like this:
<form name="websignup" method="POST"
action="http://servername/database/gendoc?createdocument">
<label for="name">Your Name</label>
<input type="text" name="name" /><br />
<label for="email">Your Email</label>
<input type="text" name="email" /><br />
<label for="interest">Your Interest(s)</label><br />
<textarea name="interest"></textarea>
<input type="submit" value="Sign Up!" />
</form>
Author's Note: This example shows how you can create documents from HTML sources and publish them to Domino databases, but the very same approach can be used from within Domino databases. Simply create a blank navigator called "webform", and a form element called "$$NavigatorTemplate for webform", set the Content Type to HTML, and add your HTML. This way, you can use the relative URL link action to point to the "gendoc" form, and "keep it Domino" for those of you who aren't able to/don't have other web servers/engines.
My next entry (published either tonight or tomorrow) will talk about editing Domino content via the URL-Command Method. After that, we start talking about how you can create a session with your Domino database via Agent-based POST actions to get some amazing functionality.