OpenWGA 7.10 - OpenWGA Concepts and Features

Design and development » HDBModel framework

Creating and updating content via WebTML forms

HDBModel contents can be created using a simple WebTML form and in many situations without any custom TMLScript code. You just have to specify the following:

  • Specify <tml:form> attribute source="none"
  • Specify the contentclass of the content to create in <tml:form> attribute contentclass
  • Provide a <tml:button> or any other action link which triggers default action $store

Like on this example form:

<tml:form id="newcustomer" source="none" contentclass="customer">


  Name: <tml:input name="name"/><br>

 

  Customer since: <tml:input name="customersince" type="date"/><br>


  <tml:button clickaction="$store">Save</tml:button>

</tml:form>

On executing default action "$store" HDBModel will automatically determine the right place to store the new content based on the hierarchy definition.

This approach is absolutely sufficient for creating contents that have no "parent content" up the hierarchy, like the "customer" content on the example. HDBModel needs no context information for finding the right place for those. However when you want to create a child content document, which is defined "below" some other content in the hierarchy definition, then HDBModel needs to know the parent content to use. You specify this parent content via the WebTML context under which the <tml:form> tag is rendered. This either has to be:

  • on the parent content itself, or
  • on the storage under which the child content is to be stored.

According to the example definition given in Planning the document hierarchy this means a <tml:form contentclass="task"> either needs to be run under the context of a "project" document, or one of the "tasks" storage documents. With this given the $store action is able to store a new content below the determined parent content.

Updating content

Updating HDBModel content via WebTML forms is actually no different than updating other OpenWGA content:

  • Create a <tml:form> in the context of the document to update
  • Specify source="content"
  • Provide a <tml:button> or any other action link calling default action "$store"

Automatic portlet events

When creating, updating and deleting HDBModel content inside a WebTML portlet HDBModel will automatically fire portlet events. Portlets that need to react on the modification of HDBModel data may subscribe to these events via <tml:eventscript> and will get automatically reloaded.

Two portlet events are fired on every create/update/delete:

  • One event of name "hdbupdate" with the following event parameters
    • "key" - The content key of the created/updated/deleted document
    • "contentclass" - The content class of the modified document
    • "type" - The type of event. One of "create", "update" or "delete"
  • One event of name "hdbupdate-<contentclass>", where <contentclass> is the content class of the modified document, carrying the following parameters
    • "key" - The content key of the created/updated/deleted document
    • "type" - The type of event. One of "create", "update" or "delete"
Portlets may choose to listen to one of both events, depending on their need to react on any modification or on modification of certain content classes only.