You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Gerry Kaplan <gk...@metroweb.us> on 2004/10/27 07:08:57 UTC

Help with Modular Database definition

I am trying to create a sitemap that, after validating a form, will add the
fields to a MySQL database. The database definitions are as follows:
 
<root>
   <connection>imweb</connection>
 
   <table name="reports" alias="reports">
      <keys>
         <key name="ReportId" type="int" autoincrement="true">
            <mode name="auto"  type="autoincr"/>
         </key>
      </keys>
      <values>
         <value name="UserId"  type="string"></value>
         <value name="ReportRef" type="string"></value>
         <value name="PatName"  type="string"></value>
         <value name="CreationDate" type="time-stamp"></value>
         <value name="ModifiedDate" type="time-stamp"></value>
         <value name="ExamDate"  type="date"></value>
         <value name="ReportXML" type="blob"></value>
      </values>   
   </table>
 
   <table-set name="add-report">
      <table name="reports"/>
   </table-set>
</root>


The form that is displayed contains only three input fields:
1.  reports.ReportRef
2.  reports.PatName
3.  reports.ExamDate

The session contains a single attribute named:  userId 

Somehow, I need to 
1. Populate "CreationDate" and "ModifiedDate" with the current datetime
(timestamp).
2. Populate the "UserId" field with the value of the session attribute
"userId".

Can anyone help with how to use the InputModules in order to do these two
requirements?

Thanks! Below are additional details that may help.

My sitemap <actions> section contains the following:

<map:action name="create-report"
src="org.apache.cocoon.acting.modular.DatabaseAddAction">
   <descriptor>content/defs/database.xml</descriptor>
   <throw-exception>true</throw-exception>
</map:action>

... And later in the sitemap, it is used as follows:

<map:select type="simple">
   <map:parameter name="value" value="{request:method}"/>
   <map:when test="POST">
      <map:act type="form-validator">
         <map:parameter name="descriptor"
value="context://imweb/content/defs/new-report.xml"/>
         <map:parameter name="constraint-set" value="new"/>

         <!-- SUCCESSFUL FORM VALIDATION -->
         <map:act type="create-report">
            <map:parameter name="table-set" value="add-report"/>
            <map:redirect-to uri="myReports"/>
         </map:act>		

      </map:act>
   </map:when>
</map:select>




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org