Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents


Description

The text field widget is a basic labeled input widget with a small area for text representing an int, decimal or string basic data type.

Is allows for binding of values to basic variables or attributes of objects instances in a unit.

It also allows for binding to a variable, object instance attribute or function in order to determine if the widget is hidden or not.

The title is specified as a key to a lang file entry and is required.

In addition, the text field widget provides a datatype attribute that can be used to slightly alter the behaviour of the text field widget. Possible values and their related behaviour is as follows:

datatype="number"Allows only numbers to be entered. Provides scroller buttons that increment and decrement the current value.
datatype="password"

Displays a * character instead of the characters entered by the user in order to hide a password.

datatype="text"Default behaviour assuming the widget is bound to a basic data type that is not of type int.
datatype="tel"
Provides additional validation for phone numbers.
datatype="email"
Provides additional validation for email addresses.
datatype="url"
Provides additional validation for URLs.

Note that when the text field is bound to a variable of type int it will behave as though datatype="number" has been specified even though it hasn't.

The title is specified as a key to a lang file entry and is required. A tooltip can also be specified as a key to a lang file entry but is optional. Visibility bindings are also supported.


Example

Implied number datatype

The abbreviated code snippets and screenshot below shows the use of <textfield/> with a value binding to an object instance attribute and a visibility binding to a unit function. It uses the default datatype behaviour.

Code Block
languagexml
titleView XML
linenumberstrue
 <textfield label="textfield.quantity_to_purchase">
	<visible function="showPurchaseForm"/>
    <binding variable="farmerPurchase">
		<attribute name="purchaseQuantity"/>
	</binding>
</textfield>


Code Block
languagejava
titleBacking unit
linenumberstrue
FarmerPurchase farmerPurchase;
bool makingPurchase;
bool stockItemSelected;

void init() {
    farmerPurchase = FarmerPurchase:new();
    makingPurchase = true;
    stockItemSelected = false;
}
.
.
.
bool showPurchaseForm() {
    if(makingPurchase == true && stockItemSelected == true) {
        return true;
    }
    return false;
}


Code Block
titleen.lang file entry
 textfield.quantity_to_purchase = Quantity to purchase:


Info
title<textfield> bound to int type or using datatype="number"

Password datatype

Code Block
languagexml
titleView XML
linenumberstrue
<textfield label="textfield.password" datatype="password">
    <binding variable="userPassword"/>
</textfield>


Info
title<textfield> using datatype="password"

Implied text datatype

Code Block
languagejava
titleModel object attribute
linenumberstrue
persistent object SystemAdmin {
    
    @requiredFieldValidator("validator.required_field")
    string firstName;
    .
    .
}


Code Block
languagexml
titleView XML
linenumberstrue
<textfield label="textfield.first_name">
    <binding variable="systemAdmin">
        <attribute name="firstName"/>
    </binding>
</textfield>


Info
title<textfield> not bound to an int type and using the default behaviour




Additional Mentions and References