pp108 : RichText

RichText

 


The RichText control can display multi-line, formatted text at run time. It is a WYSIWYG control that provides basic editing functionality to add and format text in an XForm at design-time.

Double-click the control to open the editor for editing the code in design-time.

The following formatting options are available in the control. To apply formatting, select the text and then select the appropriate option.

Table 1. List of Formatting Options

Icon

Description

Highlights the selected text as bold.

Highlights the selected text as italics.

Underlines the selected text.

Strikes the selected text.

Left-aligns the selected text.

Center-aligns the selected text.

Right-aligns the selected text.

Displays the selected text paragraphs as an ordered list.

Displays the selected text paragraphs as an unordered, bulleted list.

Indents the selected text.

Outdents the selected text.

Formats the selected text as a Subscript.

Formats the selected text as a Superscript.

Adds a horizontal line at the pointer position.

Provides color options to change the color of the selected text.

Highlights the selected text.

Adds a table.

Adds a row below the selected row in the table.

Adds a row above the selected row in the table.

Adds a column to the right of the selected column in the table.

Adds a column to the left of the selected column in the table.

Deletes the selected row.

Deletes the selected column.

Size

Displays options in a drop-down list to set the size of the selected text.

Font

Displays options in a drop-down list to set the font of the selected text.

Format

Displays options in a drop-down list to format the selected text.



RichText controls can be free-form or data-bound controls. You can use a free-form RichText control to display any arbitrary multi-line text. When data-bound, the control is associated to a model from which it fetches data. To bind a control and retrieve data from a model, you need to specify the model and set a reference to the business object from which to display the data.

You can specify the model in the property sheet of the RichText control. If no model is set for the control, then the control is bound to the model of its parent control, by default.

You can set the reference of the business object inline with the text in the control. To set reference, specify the business object's XPath inline using the$<Reference XPath>$format.

Properties, Events, and Methods of the Control


The properties, events, and methods associated with the RichText control define its behavior. You can set them either through the control's property sheet or programmatically using the APIs. For details, see RichTextEditor.

The following XForms-related properties, events, and methods are available for the control:

Table 2. List of Properties

Design-time property

Run-time property

Description

ID

 

Sets the string that identifies the control on an XForm. If not specified, a unique ID is automatically generated.

Model

 

Sets the ID of the data model from which the data is displayed in the control. If model is not specified, it is inherited from the parent control's model.

Class Name

className

Sets or retrieves the class name applied on the control.

 

businessObject

Retrieves the root node of the XML data associated with the control; the location of the data is specified by the Reference property.

 

currentContext

Retrieves the immediate parent of the data that the control represents. This data is the child node of the business object.

 

data

Retrieves the XML node of the data (value) that the control represents. The location (XPath) of this XML inside the business object is set through the Reference property.

 

Table 3. List of Events

Event

Description

Data Bind

This event is activated before the data is bound to the control.

 

Table 4. List of Methods

Method

Description

addListener(sEventName, fpFunction)

This method registers a function to an event, such that the function gets called when the event is fired on the control.

disable()

This method disables the control on which it is invoked.

enable()

This method enables the control on which it is invoked.

getBusinessObject()

This method retrieves data or business object.

getValue()

This method returns the original value of the control, as available in the database.

hide()

This method hides controls and all associated child controls.

isEnabled()

This method retrieves the value that denotes whether the control is enabled or not.

rebind(oBusinessObject)

This method is available for controls bound to a model. It refreshes the control with data from the business object that is passed as a parameter. If no parameter is passed, the business object of the model'sactiveTuplenode is used to refresh the control.

removeListener(sEventName, fpFunction)

This method unregisters a function from an event, such that the function stops getting called when the event is fired on the control.

setValue()

This method sets the value of the control.

show()

This method makes the control and its child controls visible.