A Word About Actions

Actions interact with models to implement the aplication specific logic, they serve to offer interaction between incoming requests and the business model. All data retrival (database access, flatfiles and etc) should be encapsulated in actions. An action also handles all the validation requirements and all error handling.

RequestMethods and Action Execution

Request methods are a concept in Agavi that abstracts from the HTTP verbs GET/POST/PUT etc to more general terms that are applicable in any environment. Agavi can be used in SOAP, XML-RPC, console and other contexts where HTTP may not be involved. The most common methodnames are Read and Write, but others like Create and Delete exist and you can define your own methodnames on the fly if required. The default methodnames are chosen to map nicely to the standard HTTP verbs and also fit nicely into all other environments. The default mapping for HTTP verbs is as follows:
Table 1. HTTP Verb Transations
Verb Translation
GET Read
POST Write
PUT Create
DELETE Delete
An action may respond to a specific request method by simply implementing a method named after the request method, such as executeRead to respond to GET requests or executeWrite to respond to POST requests. An action may respond to as many request methods as you wish simply by implementing more than one execute method. An action may respond to all request methods by implementing a method execute(). An action may skip all exection by simply defining a method isSimple() and returning a boolean true. If an action does not respond to a request method, the default method getDefaultView() is called.