Example: The Single Action Form
Using the HadronZoo naming convention, a single action form called "MyForm" whose purpose is to create/edit instances of "MyClass", is defined within a page or article either as:-
<xformDef name="form_MyForm" class="MyClass" action="fhdl_MyForm" url="/MyForm"> <xbutton name="Button"/> </xformDef>
Or:-
<xformDef name="form_MyForm" class="MyClass"> <xbutton name="Button" action="fhdl_MyForm" url="/MyForm"/> </xformDef>
If the same single action form were to be defined independently and then referenced, the <xformDef> and <xbutton> tags MUST NOT contain URLs. So:-
<xformDef name="form_MyForm" class="MyClass" action="fhdl_MyForm"> <xbutton name="Button"/> </xformDef>
Or:-
<xformDef name="form_MyForm" class="MyClass"> <xbutton name="Button" action="fhdl_MyForm"/> </xformDef>
The form is referenced by <xformRef form="form_MyForm" context="MyClass" url="/MyForm"/>. Each reference though, would have to use a different URL.
The above configs result in:-
1) | A single form definition named "form_MyForm" being created. |
2) | An entry in hdsApp::m_FormDefs with the form definition name "form_MyForm" as key and the form definition pointer as object. |
3) | For each page/article in which the form is referenced by an <xformRef>, a single form reference is created and a pointer to it is inserted into the visible entities of the page or article. |
4) | For each form action an entry in hdsApp::m_FormHdls with the form handler name of as key and a Null form handler pointer as object. |
5) | An entry in hdsApp::m_FormsUrl2Hdl with the URL of "/MyForm" as key and the form handler name "fhdl_MyForm" as object. |
6) | An entry in hdsApp::m_FormsUrl2Ref with the URL of "/MyForm" as key and the form reference pointer as object. |
7) | An entry in hdsApp::m_FormsRef2Url with the form reference pointer as key and the URL of "/MyForm" as object. |
Example: The Multiple Action Form
Again using the HadronZoo naming convention, a multiple action form called "MyForm" for the same purpose, is defined within a page or article either as:-
<xformDef name="form_MyForm" class="MyClass" action="fhdl_MyForm" url="/MyFormA"> <xbutton name="ButtonA" action="fhdl_MyFormA"/> <xbutton name="ButtonB" action="fhdl_MyFormB" url="/MyFormB/> </xformDef>
Or:-
<xformDef name="form_MyForm" class="MyClass"> <xbutton name="ButtonA" action="fhdl_MyFormA" url="/MyFormA"/> <xbutton name="ButtonB" action="fhdl_MyFormB" url="/MyFormB"/> </xformDef>
Or in the independent case as either:-
<xformDef name="form_MyForm" class="MyClass" action="fhdl_MyForm""> <xbutton name="ButtonA" action="fhdl_MyFormA"/> <xbutton name="ButtonB" action="fhdl_MyFormB"/> </xformDef>
Or:-
<xformDef name="form_MyForm" class="MyClass"> <xbutton name="ButtonA" action="fhdl_MyFormA"/> <xbutton name="ButtonB" action="fhdl_MyFormB"/> </xformDef>
The form is referenced by <xformRef form="form_MyForm" context="MyClass" url="/MyFormA" url="/MyFormB"/>
The above configs result in:-
1) | A single form definition named "form_MyForm" being created. |
2) | An entry in hdsApp::m_FormDefs with the form definition name "form_MyForm" as key and the form definition pointer as object. |
3) | For each page/article in which the form is referenced by an <xformRef>, a single form reference is created and a pointer to it is inserted into the visible entities of the page or article. |
4) | An entry in hdsApp::m_FormHdls with the name of "fhdl_MyForm" as key and a Null form handler pointer as object. |
5) | An entry in hdsApp::m_FormsUrl2Hdl with the URL of "/MyForm" as key and the form handler name "fhdl_MyForm" as object. |
6) | An entry in hdsApp::m_FormsUrl2Ref with the URL of "/MyForm" as key and the form reference pointer as object. |
7) | An entry in hdsApp::m_FormsRef2Url with the form reference pointer as key and the URL of "/MyForm" as object. |
Note the entry in hdsApp::m_FormHdls awaits a subsequent <xformHdl> to define the form handler. The name is only reserved within the bounds of <xformDef>. Note also that in the above <xformRef> tag, the context attribute is set to 'MyClass'. If the data class 'MyClass' was being used as a sub-class in a member called 'MyClasses' of a parent data class 'MyBigClass', the context attribute would be 'MyBigClass.MyClasses'.