HtmlConnector
Module | ejs.web |
Definition | class HtmlConnector |
Inheritance | HtmlConnector ![]() |
The Html Connector provides bare HTML encoding of Ejscript controls.
Properties
Qualifiers | Property | Type | Description |
---|---|---|---|
No properties defined |
HtmlConnector Methods
Qualifiers | Method |
---|---|
aform(record: Object, url: String, options: Object): Void | |
Render an asynchronous (ajax) form. | |
alink(text: String, url: String, options: Object): Void | |
Emit an asynchronous (ajax) link to an action. | |
button(value: String, buttonName: String, options: Object): Void | |
Render a form button. | |
buttonLink(text: String, url: String, options: Object): Void | |
Render a link button. | |
checkbox(name: String, value: String, submitValue: String, options: Object): Void | |
Render an input checkbox. | |
endform(): Void | |
End an input form. | |
extlink(text: String, url: String, options: Object): Void | |
Emit an application relative link. | |
flash(kind: String, msg: String, options: Object): Void | |
Emit a flash message area. | |
form(record: Object, url: String, options: Object): Void | |
Render a form. | |
HtmlConnector(controller) | |
image(src: String, options: Object): Void | |
Render an image control. | |
label(text: String, options: Object): Void | |
Render a text label field. | |
link(text: String, action: String, options: Object): Void | |
Emit a link to an action. | |
list(field: String, choices: Object, defaultValue: String, options: Object): Void | |
Emit a selection list. | |
mail(nameText: String, address: String, options: Object): Void | |
Emit a mail link. | |
radio(name: String, selected: String, choices: Object, options: Object): Void | |
Emit a radio autton. | |
script(url: String, options: Object): Void | |
Emit a script link. | |
stylesheet(url: String, options: Object): Void | |
Emit a style sheet link. | |
table(data, options: Object = null): Void | |
Render a table.param options. | |
tabs(initialData: Array, options: Object): Void | |
Render a tab control. | |
text(name: String, value: String, options: Object): Void | |
Render a text input field as part of a form. | |
textarea(name: String, value: String, options: Object): Void | |
Render a text area. |
Method Detail
Render an asynchronous (ajax) form.
- Parameters
record: Object Initial data. url: String Action to invoke when the form is submitted. Defaults to "create" or "update" depending on whether the field has been previously saved. options: Object Optional extra options. See getOptions for a list of the standard options.
- Options
url String Use a URL rather than action and controller for the target url.
Emit an asynchronous (ajax) link to an action.
- Description
- The URL is constructed from the given action and the current controller. The controller may be overridden by setting the controller option.
- Parameters
text: String Link text to display. url: String Action to invoke when the link is clicked. options: Object Optional extra options. See getOptions for a list of the standard options.
- Options
controller String Name of the target controller for the given action. url String Use a URL rather than action and controller for the target url.
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.
- Parameters
value: String Text to display in the button. options: Object Optional extra options. See getOptions for a list of the standard options. Examples: button("OK", "commit") button("Cancel", "commit") buttonName: String
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.
- Parameters
text: String Text to display in the button. url: String Override target URL to use instead of action. options: Object Optional extra options. See getOptions for a list of the standard options
Render an input checkbox.
- Description
- This creates a checkbox suitable for use within an input form.
- Parameters
name: String Name of the field to display. This is used to create a HTML "name" and "id" attribute for the input element. If used inside a model form, it is the field name in the model containing the checkbox value to display. If used without a model, the value to display should be passed via options.value. value: String Value to display. submitValue: String Value to submit if checked. Defaults to "true". options: Object Optional extra options. See getOptions for a list of the standard options.
endform(): Void
End an input form.
- Description
- This closes an input form initiated by calling the form method
Emit an application relative link.
- Description
- If invoking an action, it is safer to use \a action.
- Parameters
text: String Link text to display. url: String Action or URL to invoke when the link is clicked. options: Object Optional extra options. See getOptions for a list of the standard options
Emit a flash message area.
- Parameters
kind: String Kind of flash messages to display. msg: String Flash message to display. options: Object Optional extra options. See getOptions 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") %> * <% flash() %> * <% flash(["error", "warning"]) %>
Render a form.
- Parameters
record: Object Model record to edit. url: String Action to invoke when the form is submitted. Defaults to "create" or "update" depending on whether the field has been previously saved. options: Object Optional extra options. See getOptions for a list of the standard options.
- Options
url String Use a URL rather than action and controller for the target url.
Render an image control.
- Parameters
src: String Optional initial source name for the image. The data option may be used with the refresh option to dynamically refresh the data. options: Object Optional extra options. See getOptions for a list of the standard options
- Example
<% image("myPic.gif") %> <% image("myPic.gif", { data: "getData", refresh: 2, style: "myStyle" }) %>
Render a text label field.
- Description
- This renders an output-only text field. Use text() for input fields.
- Parameters
text: String Optional initial data for the control. The data option may be used with the refresh option to dynamically refresh the data. options: Object Optional extra options. See getOptions for a list of the standard options
- Example
<% label("Hello World") %> <% label(null, { data: "getData", refresh: 2, style: "myStyle" }) %>
Emit a link to an action.
- Description
- The URL is constructed from the given action and the current controller. The controller may be overridden by setting the controller option.
- Parameters
text: String Link text to display. action: String Action to invoke when the link is clicked. options: Object Optional extra options. See getOptions for a list of the standard options.
- Options
controller String Name of the target controller for the given action. url String Use a URL rather than action and controller for the target url.
Emit a selection list.
- Parameters
field: String Name of the field to display. This is used to create a HTML "name" and "id" attribute for the input element. If used inside a model form, it is the field name in the model containing the list item to select. If used without a model, the value to select should be passed via options.value. choices: Object Choices to select from. This can be an array list where each element is displayed and the value returned is an element index (origin zero). It can also be an array of array tuples where the first tuple entry is the value to display and the second is the value to send to the app. Or it can be an array of objects such as those returned from a table lookup. If choices is null, the field value is used to construct a model class name to use to return a data grid containing an array of row objects. The first non-id field is used as the value to display. defaultValue: String Current value. options: Object Extra options Examples: list("stockId", Stock.stockList) list("low", ["low", "med", "high"]) list("low", [["low", "3"], ["med", "5"], ["high", "9"]]) list("low", [{low: 3}, {med: 5}, {high: 9}]) list("Stock Type") Will invoke StockType.findAll() to do a table lookup.
Emit a mail link.
- Parameters
nameText: String Recipient name to display. address: String Mail recipient address. options: Object Optional extra options. See getOptions for a list of the standard options
Emit a radio autton.
- Description
- The URL is constructed from the given action and the current controller. The controller may be overridden by setting the controller option.
- Parameters
name: String Name of the field to display. This is used to create a HTML "name" and "id" attribute for the input element. If used inside a model form, it is the field name in the model containing the radio data to display. If used without a model, the value to display should be passed via options.value. selected: String Selected option. choices: Object Array or object containing the option values. If array, each element is a radio option. If an object hash, then they property name is the radio text to display and the property value is what is returned. options: Object Optional extra options. See getOptions for a list of the standard options.
- Options
controller String Name of the target controller for the given action. value String Name of the option to select by default.
- Example
* radio("priority", ["low", "med", "high"]) * radio("priority", {low: 0, med: 1, high: 2}) * radio(priority, Message.priorities)
Emit a script link.
- Parameters
url: String URL for the script to load. options: Object Optional extra options. See getOptions for a list of the standard options
Emit a style sheet link.
- Parameters
url: String Stylesheet url or array of stylesheets. options: Object Optional extra options. See getOptions for a list of the standard options
Render a table.param options.
- Description
- The table control can display static or dynamic tabular data. The client table control manages sorting by column, dynamic data refreshes, pagination and clicking on rows. If the table supplies a URL or action for the data parameter, the table data is retrieved asynchronously using Ajax requests on that action/URL value. The action routine should call the table() control to render the data and must set the ajax option to true.
- Parameters
data Data for the control or URL/action to supply data. If data is a String, it is interpreted as a URL or action that will be invoked to supply HTML for the table. In this case, the refresh option defines how frequently to refresh the table data. The data parameter can also be a grid of data, ie. an Array of objects where each object represents the data for a row. The column names are the object property names and the cell text is the object property values. The data parameter can also be a model instance. options: Object Optional extra options. See getOptions for a list of the standard options [default: null]
- Options
ajax Set to true if the table control is being invoked as part of an Ajax data refresh. click String Action or URL to invoke an element in the table is clicked. The click arg can be is a String to apply to all cells, a single-dimension array of strings for per-row URLs, and a two-dimension array for per cell URLs (order is row/column). 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. Column options: align, formatter, header, render, sort, sortOrder, style, width. pageSize Number Number of rows to display per page. Omit or set to <= 0 for unlimited. Defaults to unlimited. pivot Boolean Pivot the table by swaping rows for columns and vice-versa. query URL query string to add to click URLs. Can be a single-dimension array for per-row query strings or a two-dimensional array for per cell (order is row/column). showHeader Boolean Control if column headings are displayed. showId Boolean If a columns option is not provided, the id column is normally hidden. To display, set showId to be true. sort String Enable row sorting and define the column to sort by. sortOrder String Default sort order. Set to "ascending" or "descending".Defaults to ascending. style String CSS style to use for the table. styleColumns Array of styles to use for the table body columns. Can also use the style option in the columns option. styleBody String CSS style to use for the table body cells. styleHeader String CSS style to use for the table header. styleRows Array of styles to use for the table body rows. styleOddRow String CSS style to use for odd data rows in the table. styleEvenRow String CSS style to use for even data rows in the table. title String Table title Column options: - align
- format
- formatter
- header
- render
- sort String Define the column to sort by and the sort order. Set to "ascending" or "descending". Defaults to ascending.
- style
- Example
<% table("getData", { refresh: 2, pivot: true" }) %> <% table(gridData, { click: "edit" }) %> <% table(Table.findAll()) %> <% table(gridData, { click: "edit", sort: "Product", columns: { product: { header: "Product", width: "20%" } date: { format: date('%m-%d-%y) } } }) %>
Render a tab control.
- Description
- The tab control can display static or dynamic tree data.
- Parameters
initialData: Array Optional initial data for the control. The data option may be used with the refresh option to dynamically refresh the data. Tab data is an array of objects -- one per tab. For example: [{"Tab One Label", "action1"}, {"Tab Two Label", "action2"}]. options: Object Optional extra options. See getOptions for a list of the standard options
Render a text input field as part of a form.
- Parameters
name: String Name of the field to display. This is used to create a HTML "name" and "id" attribute for the input element. If used inside a model form, it is the field name in the model containing the text data to display. If used without a model, the value to display should be passed via options.value. value: String Text to display. options: Object Optional extra options. See getOptions for a list of the standard options.
- Options
escape Boolean Escape the text before rendering. This converts HTML reserved tags and delimiters into an encoded form. style String CSS Style to use for the control. visible Boolean Make the control visible. Defaults to true.
- Example
* <% text("name") %>
Render a text area.
- Parameters
name: String Name of the field to display. This is used to create a HTML "name" and "id" attribute for the input element. If used inside a model form, it is the field name in the model containing the text data to display. If used without a model, the value to display should be passed via options.value. value: String Text to display. options: Object Optional extra options. See getOptions for a list of the standard options.
- Options
Boolean Escape Escape the text before rendering. This converts HTML reserved tags and delimiters into an encoded form. data String URL or action to get data. numCols Number number of text columns. numRows Number number of text rows. style String CSS Style to use for the control. visible Boolean Make the control visible. Defaults to true.
- Example
* <% textarea("name") %>