View
| Module | ejs.web |
| Namespace | "ejs.web" |
| Definition | dynamic class View |
| Inheritance | View Object |
Base class for web framework views.
This class provides the core functionality for all Ejscript view web pages. Ejscript web pages are compiled to create a new View class which extends the View base class. In addition to the properties defined by this class, user view classes will inherit at runtime all public properites of the current controller object.
Properties
| Qualifiers | Property | Type | Description |
|---|---|---|---|
| ejs.web | controller | Controller | Current controller TODO - consistency. Should this be currentController. |
View Methods
| Qualifiers | Method |
|---|---|
| button(value: String, name: String, options: Object): Void | |
| Render a form button. | |
| buttonLink(text: String, action: String, options: Object): Void | |
| Render a link button. | |
| chart(initialData: Array, options: Object): Void | |
| Render a chart. | |
| checkbox(field: String, value: String, options: Object): Void | |
| Render an input checkbox. | |
| createSession(timeout: Number): Void | |
| Enable session control. | |
| currency(fmt: String): String | |
| Temporary helper function to format a number as currency. | |
| d(args: Array): Void | |
| Dump objects for debugging. | |
| date(fmt: String): String | |
| Temporary helper function to format the date. | |
| destroySession(): Void | |
| Destroy a session. | |
| endform(): Void | |
| End an input form. | |
| flash(kind: String, options: Object): Void | |
| Emit a flash message area. | |
| form(record: Object, action: String, options: Object): Void | |
| format(value, renderer: Object, model: Object): String | |
| getOptions(options: Object): String | |
| Map options to a HTML attribute string. | |
| html(args: Array): String | |
| HTML encode the arguments. | |
| image(name: String, options: Object): Void | |
| Render an image control. | |
| label(field: String, options: Object): Void | |
| Render a text label field. | |
| link(text: String, action: String, options: Object): Void | |
| Emit a link to an action. | |
| linkUrl(text: String, url: String, options: Object): Void | |
| Emit a link. | |
| list(field: String, choices: Object, options: Object): Void | |
| mailLink(address: String, name: String, options: Object): Void | |
| Emit a mail link. | |
| makeUrl(action: String, id: String, options: Object): String | |
| Duplicate Controller. | |
| number(fmt: String): String | |
| Temporary helper function to format a number. | |
| progress(initialData: Array, options: Object): Void | |
| Emit a progress bar. | |
| radio(field: String, values: Object, options: Object): Void | |
| Emit a radio autton. | |
| redirect(action: String, id: String, options: Object): Void | |
| Redirect to the given action Options: id controller. | |
| redirectUrl(url: String, code: Number): Void | |
| Redirect the client to a new URL. | |
| public | render(): Void |
| Process and emit a view to the client. | |
| setCookie(name: String, value: String, lifetime: Number, path: String, secure: Boolean): Void | |
| Define a cookie header to include in the reponse TODO - reconsider arg order. | |
| setHeader(key: String, value: String, allowMultiple: Boolean): Void | |
| Of the format "keyword: value". | |
| setHttpCode(code: Number): Void | |
| Set the HTTP response status code. | |
| setMimeType(format: String): Void | |
| Set the response body mime type. | |
| status(initialData: Array, options: Object): Void | |
| Emit a status control area. | |
| table(data: Array, options: Object): Void | |
| Render a table. | |
| tabs(initialData: Array, options: Object): Void | |
| Render a tab control. | |
| text(field: String, options: Object): Void | |
| Render a text input field as part of a form. | |
| textarea(initialData: String, options: Object): Void | |
| Render a text area. | |
| tree(initialData: XML, options: Object): Void | |
| Render a tree control. | |
| View(controller: Controller) | |
| Constructor method to initialize a new View. | |
| write(args: Array): Void | |
| Duplicate Controller. | |
| writeHtml(args: Array): Void | |
| Write HTML escaped text to the client. | |
| writeRaw(args: Array): Void | |
| Duplicate Controller. |
Method Detail
Render a form button.
- Description
- This creates a button suitable for use inside an input form. When the button is clicked, the input form will be submitted.
Render a link button.
- Description
- This creates a button suitable for use outside an input form. When the button is clicked, the associated URL will be invoked.
Render a chart.
- Description
- The chart control can display static or dynamic tabular data. The client chart control manages sorting by column, dynamic data refreshes, pagination and clicking on rows.
- Parameters
initialData: Array Optional initial data for the control. The data option may be used with the refresh option to dynamically refresh the data. options: Object Object Optional extra options. See also $getHtmlOptions for a list of the standard options.
Options
columns: Object — hash of column entries. Each column entry is in-turn an object hash of options. If unset, all columns are displayed using defaults.
kind: String — Type of chart. Select from: piechart, table, linechart, annotatedtimeline, guage, map, motionchart, areachart, intensitymap, imageareachart, barchart, imagebarchart, bioheatmap, columnchart, linechart, imagelinechart, imagepiechart, scatterchart (and more)
onClick: String — Action or URL to invoke when a chart element is clicked.
- Example
- <% chart(null, { data: "getData", refresh: 2" }) %> <% chart(data, { onClick: "action" }) %>
Enable session control.
- Description
- This enables session state management for this request and other requests from the browser. If a session has not already been created, this call creates a session and sets the.
- Parameters
timeout: Number Optional timeout for the session in seconds. If ommitted the default timeout is used.
Temporary helper function to format a number as currency.
- Description
- TODO.
- Parameters
fmt: String Format string
- Returns
- A formatted string.
Temporary helper function to format the date.
- Description
- TODO.
- Parameters
fmt: String Format string
- Returns
- A formatted string.
Destroy a session.
- Description
- This call destroys the session state store that is being used for the current client. If no session exists, this call has no effect.
End an input form.
- Description
- This closes an input form initiated by calling the $form method.
Emit a flash message area.
- Parameters
kind: String TODO - incomplete options: Object Optional extra options. See $getHtmlOptions for a list of the standard options.
Options
retain: Number. — Number of seconds to retain the message. If <= 0, the message is retained until another message is displayed. Default is 0.
- Example
- <% flash("status") %>