Skip to content
neoneo edited this page Jan 25, 2012 · 4 revisions

At the beginning of the request handling by CFlow, a Response object is created. This object gathers all content that is generated by the views. Content can have different types. Currently only 'TEXT', 'HTML' and 'JSON' are implemented.

Views have direct access to this object.

The Response object has the following methods:

string getType()

Returns the content type of the response: HTML, JSON or TEXT.

void setType(required string)

Sets the content type of the response: HTML, JSON or TEXT.

string getContentType()

Returns the mime-type of the response.

void write(required any)

Appends content to the response. The content must be a string, or be serializable to JSON.

void clear()

Deletes all content from the response.

void render()

Outputs the content to the page. Depending on the content type, it does the following:

  • TEXT and HTML: all string content is concatenated and written to the output.
  • JSON: if there is exactly one content element in the response, serializes that element to JSON. If there are multiple content elements, it serializes them all in an array.

Clone this wiki locally