ZenMagick 0.9.6


org.zenmagick.rp.ZMController

Class ZMController

ZMObject
|
+--ZMController

public class ZMController
extends ZMObject

Request controller base class.

Author:
DerManoMann
Version:
$Id: ZMController.php 2173 2009-04-22 04:55:11Z dermanomann $

Fields inherited from org.zenmagick.ZMObject
properties_
Constructor Summary

ZMController(string id)

Create new instance.

Method Summary
void

exportGlobal(string name, mixed instance)

Export the given object under the given name.

ZMView

findView(string id, array parameter)

Lookup the appropriate view for the given name.

ZMView

getFormBean()

Get the form bean (if any) for this request.

void

getGlobal(string name, mixed instance)

Returns the named global.

array

getGlobals()

Returns a name => object hash of variables that need to be exported into the theme space.

string

getId()

Get the controller id.

ZMView

getView()

Get the current view.

void

handleRequest()

Generic callback for request processing independant from the method.

boolean

isFormSubmit()

Check if this request is a form submit.

ZMView

process()

Process a HTTP request.

ZMView

processGet()

Process a HTTP GET request.

ZMView

processPost()

Process a HTTP POST request.

void

setContentType(string type, string charset)

Set the response content type.

void

setId(string id)

Set the controller id.

void

setView(ZMView view)

Set the current view.

boolean

validate(string id, mixed req)

Validate the current request using the given rule id.

protected ZMView

validateFormBean(mixed formBean)

Validate the given form bean.

Methods inherited from org.zenmagick.ZMObject
attachMethod, get, getAttachedMethods, getPropertyNames, set, singleton

Constructor Detail

ZMController

public ZMController(string id)

Create new instance.

Parameters:
id - Optional id; default is null to use the request name.

Method Detail

exportGlobal

public void exportGlobal(string name, mixed instance)

Export the given object under the given name.

Controller may use this method to make objects available to the response template/view.

Parameters:
name - The name under which the object should be visible.
instance - An object.

findView

public ZMView findView(string id, array parameter)

Lookup the appropriate view for the given name.

Parameters:
id - The controller id or null to return to the current page.
parameter - Optional map of name/value pairs to further configure the view; default is null.
Returns:
The actual view to be used to render the response.

getFormBean

public ZMView getFormBean()

Get the form bean (if any) for this request.

Returns:
The actual view to be used to render the response.

getGlobal

public void getGlobal(string name, mixed instance)

Returns the named global.

Parameters:
name - The object name.
instance - An object instance or null.

getGlobals

public array getGlobals()

Returns a name => object hash of variables that need to be exported into the theme space.

Returns:
An associative array of name => object for all variables * that need to be exported into the theme space.

getId

public string getId()

Get the controller id.

Returns:
The id (page name).

getView

public ZMView getView()

Get the current view.

Returns:
The view or null.

handleRequest

public void handleRequest()

Generic callback for request processing independant from the method. /


isFormSubmit

public boolean isFormSubmit()

Check if this request is a form submit.

This default implementation will return true for all POST requests.

Returns:
true if this is a form submit request.

process

public ZMView process()

Process a HTTP request.

Supported request methods are GET and POST.

Returns:
A ZMView instance or null.

processGet

public ZMView processGet()

Process a HTTP GET request.

Returns:
A ZMView that handles presentation or null * if the controller generates the contents itself.

processPost

public ZMView processPost()

Process a HTTP POST request.

Returns:
A ZMView that handles presentation or null * if the controller generates the contents itself.

setContentType

public void setContentType(string type, string charset)

Set the response content type.

Parameters:
type - The content type.
charset - Optional charset; default is utf-8; null will omit the charset part.

setId

public void setId(string id)

Set the controller id.

Parameters:
id - The id (page name).

setView

public void setView(ZMView view)

Set the current view.

Parameters:
view - The view or null.

validate

public boolean validate(string id, mixed req)

Validate the current request using the given rule id.

Parameters:
id - The ZMRuleSet id.
req - A (request) map, an object or null to default to $_POST.
Returns:
true if the validation was successful, false if not.

validateFormBean

protected ZMView validateFormBean(mixed formBean)

Validate the given form bean.

Parameters:
formBean - An object.
Returns:
Either the error view (in case of validation errors), or null for success.

ZenMagick 0.9.6