Vending documents: displaying HTML pages

To have your POD display HTML pages, your POD must register a PODSDocumentSrc object that implements documentForUrl() and documentForSubmission(). For sample code illustrating the use of these methods, see DocumentSrc sample: vending documents.

These methods are inherited by the PODSDocumentMgr object. When your POD executes documentForUrl() or documentForSubmission() from PODSDocumentMgr, these methods examine every registered document source until a match is found: documentForUrl() returns a document for that URL; documentForSubmission() returns a document for that submission object.

If either documentForUrl() or documentForSubmission() fail to find a match, they return a NULL PODSDocument object, along with a handled argument set to PODS_FALSE. For details on these PODSDocumentMgr methods, see:

Note

The documentForUrl() and documentForSubmission() methods can also set handled to PODS_TRUE and still return NULL. This is useful if handling the URL or submission does not involve displaying a response. For example, the URL or submission could simply change the state of M-Business Client.

More information on displaying HTML pages follows below. For an example of a POD that submits a form, see the sample code for Pod sample: submitting forms.

Your POD can create a document using PODSDocumentMgr object's createDocument( ) and then use the attributes from PODSObject object to add to it.

The following example uses createDocument( ) to create a document:

static PODSDocument *DocumentSrcDocumentForUrl(
           PODSDocumentSrc *podsDocSrc, 
           PODSString url, PODSBoolean *handled)
{
   DocumentSrc *self = (DocumentSrc *)podsDocSrc;

   if (0 == stricmp(url, SAMPLE_URL)) {
      PODSDocument *doc = 
           PODScreateDocument(self->documentMgr, 
           SAMPLE_URL, PODS_HTML_TYPE);
      ADOMHTMLDocument *dom = PODSgetDom(doc);
      ADOMElement *body;
      ADOMText *node;

      ADOMsetTitle(dom, (ADOMString)"Hello World!");

      body = ADOMcreateElement(dom, (ADOMString)"body");
      ADOMappendChild(dom, (ADOMNode *)body);

      node = ADOMcreateTextNode(dom, (ADOMString)"Hello World!");
      ADOMappendChild(body, (ADOMNode *)node);

      if (handled)
         *handled = PODS_TRUE;

      return doc;
   }

   return NULL;
}