pp108 : CodeSnippet

CodeSnippet


The CodeSnippet (earlier called 'Text') control is used to add code snippets to a page. The control preserves all formatting associated with the code snippet, including the style and font formats.

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

Note:

  • Ensure to provide any textual content within the opening and closing tags of the element.
  • Empty DIV elements must have a closing tag, with space or an empty comment instead of the text. For example,
    <div> </div>
    or
    <div><!></div>


Properties, Events, and Methods of the Control


The CodeSnippet control has certain properties, events, and methods associated with it. They define the behavior of the control and can be set through the property page of the control or programmatically using the APIs.

Table 1. List of Properties

Design-time property

Runtime 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 (specified using the Reference property) is displayed in the control. If model is not specified, it is inherited from the parent control's model.

Reference (xql)

Sets the location or expression for the XPath that contains the data (value) displayed in the control. The XPath refers to the child node or descendants of the immediate parent control's reference.

Class Name

className

Sets or retrieves the class name applied on the control.

Zoom URL

Sets the URL of the Zoom (lookup) page to be opened when the zoom button next to a control is clicked.

Zoom Field

Sets the location or XPath expression that contains the data to be set to the control when the Zoom (lookup) page is closed.

ClickChoice Relation

Sets the properties of the related application to be opened when a context-menu option of the control is selected. All the necessary properties of the application (including the name of context-menu option) is set through this property.

Task Part

Creates a task part for the control. Selecting the check box, displays the Task Part pane.

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 2. List of Events

Event

Description

Data Bind

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

onafterzoom

This event is activated before the lookup page is closed.

onbeforezoom

This event is activated before the lookup page is opened.


Table 3. 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.