32.1. The controller

This diagram shows the interaction between the Controller class that receives the incoming http request and all the other classes that manage the event creation and its procession.

32.1.1. Steps

  • The controller servlet gets the incoming http request that contains the data to process; the request object contains also the data that identify the event to instantiate and execute.

    Then, the controller instantiates the EventEngine object.

  • The controller servlet calls the eventEngine.generatePrimaryEvent() method. generatePrimaryEvent() gets the action parameter from the request, try to identify the related event type (database or navigation) and then uses the appropriate factory to create the related event object. generatePrimaryEvent() returns the event object to the controller.

  • The controller servlet checks if the returned event object is an instance of a Database event (i.e.: insert, delete, update events). If yes, validate the incoming data (the validation step occurs only if the formValidatorName request parameter exist and the current event is an Update or Insert event. The controller executes the doValidation() method that uses the Commons-Validator Jakarta component) and process the event object.

    Note: the Navigation events are managed by the DbFormsTag class. The controller manages only the database events.

  • The controller servlet stores the event reference into the session context. MUST UPDATE the diagram picture...

  • The controller servlet checks if the evetEngine has got involved tables: it find out which tables where on the jsp page (the view); one jsp file may contain multiple (db)forms, and each forms could contain many subforms nested inside.

    If yes, the controller gets the list of all the involved tables, generates and executes update events for all of them.

  • The controller servlet forwards the client to the target resource referred from the followUp attribute of the jsp form if there are no errors. Else redirects to the resource specified by the followUpOnError form attribute.