HtmlConnector

Moduleejs.web
Definition class HtmlConnector
InheritanceHtmlConnector inherit Object

The Html Connector provides bare HTML encoding of Ejscript controls.


Properties

QualifiersPropertyTypeDescription
No properties defined

HtmlConnector Methods

QualifiersMethod
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

aform(record: Object, url: String, options: Object): Void

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
urlString Use a URL rather than action and controller for the target url.

alink(text: String, url: String, options: Object): Void

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
controllerString Name of the target controller for the given action.
urlString Use a URL rather than action and controller for the target url.

button(value: String, buttonName: String, options: Object): Void

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

buttonLink(text: String, url: String, options: Object): Void

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

checkbox(name: String, value: String, submitValue: String, options: Object): Void

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

extlink(text: String, url: String, options: Object): Void

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

flash(kind: String, msg: String, options: Object): Void

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
retainNumber. 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"]) %>

form(record: Object, url: String, options: Object): Void

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
urlString Use a URL rather than action and controller for the target url.

image(src: String, options: Object): Void

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" }) %>

label(text: String, options: Object): Void

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" }) %>

link(text: String, action: String, options: Object): Void

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
controllerString Name of the target controller for the given action.
urlString Use a URL rather than action and controller for the target url.

list(field: String, choices: Object, defaultValue: String, options: Object): Void

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.

mail(nameText: String, address: String, options: Object): Void

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

radio(name: String, selected: String, choices: Object, options: Object): Void

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
controllerString Name of the target controller for the given action.
valueString 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)

script(url: String, options: Object): Void

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

stylesheet(url: String, options: Object): Void

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

table(data, options: Object = null): Void

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
ajaxSet to true if the table control is being invoked as part of an Ajax data refresh.
clickString 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).
columnsObject 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.
pageSizeNumber Number of rows to display per page. Omit or set to <= 0 for unlimited. Defaults to unlimited.
pivotBoolean Pivot the table by swaping rows for columns and vice-versa.
queryURL 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).
showHeaderBoolean Control if column headings are displayed.
showIdBoolean If a columns option is not provided, the id column is normally hidden. To display, set showId to be true.
sortString Enable row sorting and define the column to sort by.
sortOrderString Default sort order. Set to "ascending" or "descending".Defaults to ascending.
styleString CSS style to use for the table.
styleColumnsArray of styles to use for the table body columns. Can also use the style option in the columns option.
styleBodyString CSS style to use for the table body cells.
styleHeaderString CSS style to use for the table header.
styleRowsArray of styles to use for the table body rows.
styleOddRowString CSS style to use for odd data rows in the table.
styleEvenRowString CSS style to use for even data rows in the table.
titleString 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) }
    }
 }) %>

tabs(initialData: Array, options: Object): Void

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

text(name: String, value: String, options: Object): Void

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
escapeBoolean Escape the text before rendering. This converts HTML reserved tags and delimiters into an encoded form.
styleString CSS Style to use for the control.
visibleBoolean Make the control visible. Defaults to true.
Example
*       <% text("name") %>

textarea(name: String, value: String, options: Object): Void

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
BooleanEscape Escape the text before rendering. This converts HTML reserved tags and delimiters into an encoded form.
dataString URL or action to get data.
numColsNumber number of text columns.
numRowsNumber number of text rows.
styleString CSS Style to use for the control.
visibleBoolean Make the control visible. Defaults to true.
Example
*       <% textarea("name") %>